Emoji for symfony, using utf8mb4 in orm model
Come back
31

Emoji for symfony, using utf8mb4 in orm model

Emoji (emoji or emoji) 🙂 are text or graphic emoticons and symbols that are used instead of words to convey emotions, mood or some kind of meaning on sites.

Now let's start changing the data in the files to use emoji emoticons on our website.

We will change the display encoding to utf8mb4, so that the saved data is displayed on the page, in our case, these will be emoji emoticons. And we will indicate in the orm model through the parameter collate in what format will the field be stored in the database for comparison. Is in database queries like collate it is applied as changing the comparison of the field value, if you execute various queries to the database using php code.

Let's move on to action:
1) Let's write in the file config.yml entries for adding encoding, for displaying and storing emoji:

adding encoding to config.yml
2) We will register in orm model for our desired table encoding and comparison utf8mb4:

in the orm model we will write the comparison utf8mb4
3) Further in the same table we will write down the comparison utf8mb4 for the field $titleList (you will have your own field that will need to apply this comparison):
in the orm model we will write utf8mb4 for the field
4) After all the changes made in the orm models, we will update the database (using a command in the terminal or command line):

5) Clean up the symfony cache to make the encoding work completely (using a command in the terminal or command line):


!!! Attention, the field will not be cleared or deleted, but only its comparison will change. If, for some reason, delete or change a variable in the orm model, then the field may be deleted.

created:
30.12.2021
updated:
15.11.2022
author:
admin
Tags
yandex metrika