I am using Doctrine with Symfony2. My config.yml file looks something like this:-
doctrine:
dbal:
driver: %data
UPDATE:
See Symfony3.1 book for reference (click here):
Also notice the use of utf8mb4 instead of plain utf8. ("Symfony recommends utf8mb4 against MySQL's utf8 character set, since it does not support 4-byte unicode characters, and strings containing them will be truncated. This is fixed by the newer utf8mb4 character set.")
Setting UTF8 defaults for MySQL is as simple as adding a few lines to your configuration file (typically my.cnf):
[mysqld]
# Version 5.5.3 introduced "utf8mb4", which is recommended
collation-server = utf8mb4_general_ci # Replaces utf8_general_ci
character-set-server = utf8mb4 # Replaces utf8
You can also change the defaults for Doctrine so that the generated SQL uses the correct character set.
# app/config/config.yml
doctrine:
dbal:
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
You can refer to the documentation here http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html if you are using ORMs like Doctrine.
Particularly: adding/editing the [mysqld]
block in your my.cnf (usually found in /etc/my.cnf or xampp/mysql/my.cnf)
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci