symfony1.4インストールから、DB生成まで

●symfony1.4インストール

[root@localhost /]# pear channel-discover pear.symfony-project.com
Adding Channel "pear.symfony-project.com" succeeded
Discovery of channel "pear.symfony-project.com" succeeded
[root@localhost /]# pear install symfony/symfony
…
[root@localhost /]# symfony -V
symfony version 1.4.4 (/usr/share/pear/symfony)

symfonyプロジェクト作成

[root@localhost /]# cd /opt/faq
[root@localhost faq]# symfony generate project faq

●DB設定

[root@localhost config]# vi /opt/faq/config/databases.yml
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/07-Databases

all:
#  doctrine:
#    class: sfDoctrineDatabase
#    param:
#      dsn:      mysql:host=localhost;dbname=faq
#      username: root
#      password:

  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      pgsql://faq:faq@localhost/FAQ_DB
      username:   faq
      password:   faq
      encoding:   utf8
      persistent: true
      pooling:    true

スキーマ作成

[root@localhost doctrine]# vi /opt/faq/config/doctrine/schema.yml
conf_test:
  tableName: conf_test
  columns:
    id:
      type: integer(8)
      primary: true
      autoincrement: true
    name:
      type: varchar(256)
    value:
      type: varchar(1024)

●DB生成

[root@localhost faq]# symfony doctrine:build --all

  This command will remove all data in the following "dev" connection(s):

   - doctrine

  Are you sure you want to proceed? (y/N)

y
>> doctrine  Dropping "doctrine" database
>> doctrine  SQLSTATE[3D000]: Invalid catalog name: 7 ERROR:  data...does not exist. Failing Query: "DROP DATABASE FAQ_DB"
>> doctrine  Creating "dev" environment "doctrine" database
>> doctrine  SQLSTATE[42501]: Insufficient privilege: 7 ERROR:  pe...ate database. Failing Query: "CREATE DATABASE FAQ_DB"
>> doctrine  generating model classes
>> file+     /tmp/doctrine_schema_53833.yml
>> tokens    /opt/faq/lib/model/doctrine/conf_testTable.class.php
>> tokens    /opt/faq/lib/model/doctrine/conf_test.class.php
>> tokens    /opt/faq/lib/model/doctrine/base/Baseconf_test.class.php
>> autoload  Resetting application autoloaders
>> doctrine  generating form classes
>> tokens    /opt/faq/lib/form/doctrine/conf_testForm.class.php
>> tokens    /opt/faq/lib/form/doctrine/base/Baseconf_testForm.class.php
>> tokens    /opt/faq/lib/form/doctrine/BaseFormDoctrine.class.php
>> tokens    /opt/faq/lib/form/BaseForm.class.php
>> autoload  Resetting application autoloaders
>> file-     /opt/faq/cache/faq/dev/config/config_autoload.yml.php
>> doctrine  generating filter form classes
>> tokens    /opt/faq/lib/filter/doctrine/BaseFormFilterDoctrine.class.php
>> tokens    /opt/faq/lib/filter/doctrine/conf_testFormFilter.class.php
>> tokens    /opt/faq/lib/filter/doctrine/base/Baseconf_testFormFilter.class.php
>> autoload  Resetting application autoloaders
>> file-     /opt/faq/cache/faq/dev/config/config_autoload.yml.php
>> doctrine  generating sql for models
>> dir+      /opt/faq/data/sql
>> doctrine  Generated SQL successfully for models

>> doctrine  created tables successfully

●DB確認 -> conf_test が出来ていることを確認

スキーマからモデル生成

symfony propel-build-model