The definitive guide of Symfony 1.0

19.5. Controlling PHP Settings

In order to have a PHP environment compatible with the rules and best practices of agile development, symfony checks and overrides a few settings of the php.ini configuration. This is the purpose of the php.yml file. Listing 19-10 shows the default php.yml file.

Listing 19-10 - Default PHP Settings for Symfony, in $sf_symfony_data_dir/config/php.yml

set:
  magic_quotes_runtime:        off
  log_errors:                  on
  arg_separator.output:        |
    &

check:
  zend.ze1_compatibility_mode: off

warn:
  magic_quotes_gpc:            off
  register_globals:            off
  session.auto_start:          off

The main purpose of this file is to check that the PHP configuration is compatible with your application. It is also very useful to check that your development server configuration is as similar as possible to the production server. That's why you should inspect the production server configuration at the beginning of a project, and report its PHP settings in a php.yml file in your project. You can then develop and test with confidence that you will not encounter any compatibility errors once you deploy your project to the production platform.

The variables defined under the set header are modified (despite how they were defined in the server php.ini file). The variables defined under the warn category cannot be modified on the fly, but symfony can run even if they are not properly set. It is just considered bad practice to have these settings set to on, and symfony will log a warning in this case. The variables defined under the check category cannot be modified on the fly either, but they must have a certain value for symfony to run. So, in this case, an exception is raised if the php.ini file is not correct.

The default php.yml file sets log_errors to on so that you can trace errors in symfony projects. It also recommends that the register_globals be set to off to prevent security breaches.

If you don't want symfony to apply these settings, or if you want to run a project with magic_quotes_gpc and register_globals set to on without warning, then create a php.yml file in your application config/ directory, and override the settings you want to change.

Additionally, if your project requires an extension, you can specify it under the extensions category. It expects an array of extension names, as follows:

extensions: [gd, mysql, mbstring]