インストール
- ZendFrameworkをダウンロードします。
- 展開します。
- リンクをつくります。
# cd /usr/share/php
# unzip ~/download/ZendFramework-1.12.3.zip
# ln -s ZendFramework-1.12.3/library/Zend/
アプリケーションを作成
$ /usr/share/php/ZendFramework-1.12.3/bin/zf.sh create project sample
$ cd sample
$ tree
.
├── application
│ ├── Bootstrap.php
│ ├── configs
│ │ └── application.ini
│ ├── controllers
│ │ ├── ErrorController.php
│ │ └── IndexController.php
│ ├── models
│ └── views
│ ├── helpers
│ └── scripts
│ ├── error
│ │ └── error.phtml
│ └── index
│ └── index.phtml
├── docs
│ └── README.txt
├── library
├── public
│ └── index.php
└── tests
├── application
│ └── controllers
│ └── IndexControllerTest.php
├── bootstrap.php
├── library
└── phpunit.xml
16 directories, 11 files
$ ln -s /usr/share/php/ZendFramework-1.12.3/bin/zf.sh
$ ./zf enable layout
application/configs/application.ini
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Sample"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.layout.viewSuffix = php
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
/etc/httpd/conf.d/sample.conf
Alias /sample/ /some/where/sample/public/
<Directory "/some/where/sample/public/">
Order deny,allow
Allow from all
Deny from all
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteBase /content
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php
</Directory>
データベースへの接続設定
$ ./zf.sh configure db-adapter "adapter=pdo_pgsql&username=apache&password=password&dbname=sample"
application/configs/application.ini
resources.db.adapter = "pdo_pgsql"
resources.db.params.username = "apache"
resources.db.params.password = "password"
resources.db.params.dbname = "sample"