Answer the question
In order to leave comments, you need to log in
Not sure how to work with emoji in symfony?
If I specify the field type type="string" in Entity, and manually set the field type to varbinary in the database, then emoji are saved and everything works.
/**
* @ORM\Column(type="string", length=120, nullable=true)
*/
private $freeName;
/**
* @return string
*/
public function getFreeName(): ?string
{
return $this->freeName;
}
/**
* @param string $freeName
*/
public function setFreeName($freeName): self
{
$this->freeName = $freeName;
return $this;
}
* @ORM\Column(type="binary", length=120, nullable=true)
Answer the question
In order to leave comments, you need to log in
Use the utf8mb4 encoding, additionally you need to specify the parameters for the entity / table and connection.
More or less like this:
/**
* @ORM\Entity
* @ORM\Table(options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"})
*/
# app/config/config.yml
doctrine:
dbal:
charset: utf8mb4
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question