The More with symfony book

Appendice B - Esempio di installazione personalizzata

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


About

You are currently reading "The More with symfony book" which is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License license.

Master symfony

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

Books on symfony

Learn more about symfony with the official guides.
books.sensiolabs.com

L'audit Qualité par SensioLabs

200 points de contrôle de votre applicatif web.
audit.sensiolabs.com
symfony training
Be trained by symfony experts
Feb 21: Köln (Getting Started with Symfony2 - English)
Feb 27: Köln (Mastering Symfony2 - English)
Mar 05: Köln (Web Development with Symfony2 - Deutsch)
Mar 05: Montreal (Web Development with Symfony2 - English)
Mar 05: Montreal (Getting Started with Symfony2 - English)
and more...

Search


powered by google
You are currently browsing "The More with symfony book" in Italian for the 1.4 version - Switch to language:
Creative Commons License This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
More with Symfony
Support symfony!
Buy this book
or donate.
Buy More with Symfony from amazon.com

Il seguente codice PHP è un programma di installazione personalizzata utilizzato nel Capitolo 06:

<?php
 
$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');
$this->runTask('plugin:publish-assets');
if (file_exists($dir = sfConfig::get('sf_symfony_lib_dir').'/../data'))
{
  $this->installDir($dir);
}
 
$this->logSection('install', 'create the database schema');
file_put_contents(sfConfig::get('sf_config_dir').'/doctrine/schema.yml', <<<EOF
Product:
  columns:
    name:           { type: string(255), notnull: true }
    price:          { type: decimal, notnull: true }
 
ProductPhoto:
  columns:
    product_id:     { type: integer }
    filename:       { type: string(255) }
    caption:        { type: string(255), notnull: true }
  relations:
    Product:
      alias:        Product
      foreignType:  many
      foreignAlias: Photos
      onDelete:     cascade
EOF
);
 
$this->logSection('install', 'add some fixtures');
file_put_contents(sfConfig::get('sf_data_dir').'/fixtures/fixtures.yml', <<<EOF
Product:
  product_1:
    name:  Product Name
    price: 25.95
EOF
);
 
$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);
Appendice C - Licenza »
« Appendice A - codice JavaScript per sfWidgetFormGMapAddress

Questions & Feedback

If you find a typo or an error, please register and open a ticket.

If you need support or have a technical question, please post to the official user mailing-list.