Caution: You are browsing the legacy 1.x part of this website.
This version of symfony is not maintained anymore. If some of your projects still use this version, consider upgrading.

Table of Contents

This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License license.

Master Symfony fundamentals

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

Discover the SensioLabs Support

Access to the SensioLabs Competency Center for an exclusive and tailor-made support on Symfony
Blackfire Profiler Fire up your PHP Apps Performance

PHP Project Quality Done Right

Appendix B - Custom Installer Example

More with symfony
Support symfony!
Buy this book
or donate.
Buy More with symfony from

The following PHP code is a custom installer used in Chapter 06:

$this->logSection('install', 'default to sqlite');
$this->runTask('configure:database', sprintf("'sqlite:%s/database.db'", sfConfig::get('sf_data_dir')));
$this->logSection('install', 'create an application');
$this->runTask('generate:app', 'frontend');
$this->setConfiguration($this->createConfiguration('frontend', 'dev'));
$this->logSection('install', 'publish assets');
if (file_exists($dir = sfConfig::get('sf_symfony_lib_dir').'/../data'))
$this->logSection('install', 'create the database schema');
file_put_contents(sfConfig::get('sf_config_dir').'/doctrine/schema.yml', <<<EOF
    name:           { type: string(255), notnull: true }
    price:          { type: decimal, notnull: true }
    product_id:     { type: integer }
    filename:       { type: string(255) }
    caption:        { type: string(255), notnull: true }
      alias:        Product
      foreignType:  many
      foreignAlias: Photos
      onDelete:     cascade
$this->logSection('install', 'add some fixtures');
file_put_contents(sfConfig::get('sf_data_dir').'/fixtures/fixtures.yml', <<<EOF
    name:  Product Name
    price: 25.95
$this->logSection('install', 'build the model');
$this->runTask('doctrine:build', '--all --and-load --no-confirmation');
$this->logSection('install', 'create a simple CRUD module');
$this->runTask('doctrine:generate-module', 'frontend product Product --non-verbose-templates');
$this->logSection('install', 'fix sqlite database permissions');
chmod(sfConfig::get('sf_data_dir'), 0777);
chmod(sfConfig::get('sf_data_dir').'/database.db', 0777);