User Tools

Site Tools


symfony:symfony_tutorial_notes:configuring_symfony

Configuring Symfony (and Environments)

The main configuration file lives in the app/config/ as a YAML, XML, (and/?) or PHP file. Only YAML is considered here.

app/config/config.yml
imports:
    - { resource: parameters.yml }
    - { resource: security.yml }

framework:
    secret:          "%secret%"
    router:          { resource: "%kernel.root_dir%/config/routing.yml" }
    # ...
 
# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
 
# ...

Default Configuration Dump

Dump the default configuration for a bundle in YAML to the console:

$ app/console config:dump-reference FrameworkBundle  # using Bundle name
$ app/console config:dump-reference framework        # using configuration key

Environments

Different environments share the same PHP code (apart from the front controller), but use different configuration. A Symfony project generally begins with three environments: dev, test, and prod.

To clear prod cache, rebuid stuff, etc.:

$ php app/console cache:clear --env=prod --no-debug

Additional Environments

To create a new environment, copy web/app.php (or web/app_dev.php?) to a new file and in that file associate the AppKernel with a new environment name in the AppKernel ctor;

$kernel = new AppKernel('newname', false);

Then create a config file that matches the environment name but prefixed with config_:

app/config/config_newname.yml
imports:
    - { resource: config.yml }

framework:
    router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
    profiler: { only_exceptions: false }
 
# ...
symfony/symfony_tutorial_notes/configuring_symfony.txt · Last modified: 2015/09/16 23:35 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki