Info

symfony環境確認:

$ httpd -v
Server version: Apache/2.2.11 (Unix)
Server built: May 18 2009 12:37:03

$ php -v
PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:29)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

$ pear -V
PEAR Version: 1.8.0
PHP Version: 5.3.0
Zend Engine Version: 2.3.0

0. php環境設定
$ sudo cp /etc/php.ini.default /etc/php.ini
$ sudo vi /etc/php.ini
[Date]
date.timezone = Asia/Tokyo

[Pdo_mysql]
pdo_mysql.default_socket=/tmp/mysql.sock

1. Symofnyインストール(1.0.21は不具合が発生したので、1.2.8にする)
$ sudo pear channel-discover pear.symfony-project.com
$ sudo pear install symfony/symfony-1.2.8
確認:
$ symfony -V
symfony version 1.2.8 (/usr/lib/php/symfony)

インストール先:
/usr/lib/php/symfony/
/usr/lib/php/doc/symfony/
/usr/lib/php/data/symfony/

2. プロジェクト・アプリケーション作成
$ cd Sites
$ mkdir mysymfony
$ cd mysymfony
$ symfony init-project mysymfony
$ symfony init-app myapp

3. Web(Apache)サーバー環境設定
$ sudo vi /etc/apache2/users/{username}.conf

Alias /~{username}/mysymfony/ /Users/{username}/Sites/mysymfony/web/
<Directory "/Users/{username}/Sites/mysymfony/web">
   AllowOverride All
   Allow from All
</Directory>

4. .htaccess修正
RewriteRule ^(.*)$ index.php [QSA,L]
↓↓↓
RewriteRule ^(.*)$ /~{username}/mysymfony/index.php [QSA,L]

5. テーブル作成
以下のようにテーブルを作成(データベース名は各自の環境にあわせる)
mysql

6. データベース接続設定
mysymfony/config/databases.yml 編集

all:
  propel:
    class:        sfPropelDatabase
    param:
      classname:  PropelPDO
      dsn:        mysql:dbname={databasename};host=localhost
      username:   {username}
      password:   {password}
      encoding:   utf8
      persistent: true
      pooling:    true

mysymfony/config/propel.ini 編集

propel.database.url        = mysql:dbname={databasename};host=localhost
propel.database.creole.url = ${propel.database.url}
propel.database.user       = {username}
propel.database.password   = {password}
propel.database.encoding   = utf8

7. データベース定義ファイルの生成
$ symfony propel-build-schema

8. オブジェクトモデルの生成
$ symfony propel-build-model

9. フォーム作成
$ symfony propel:build-forms

10. CRUD機能の自動生成(scaffolding)
$ symfony propel-generate-crud myapp bbs Bbs
$ symfony cc

11. アクセスしてみる
http://localhost/~{username}/mysymfony/bbs

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS