PHP/フレームワーク/Zend Framework
Zend Framework †
PHP本家Zendが提供する純正フレームワーク
リファレンス †
http://www.zendframework.com/manual/ja/manual.html
インストール †
ダウンロード †
http://framework.zend.com/download
※無料の登録が必要です。
今回はコレを使用しました。
- ZendFramework-1.10.3.tar.gz
解凍して、/usr/localあたりに置いておく
# tar zxv ZendFramework-1.10.3.tar.gz # cp -rf ZendFramework-1.10.3 /usr/local/ZendFramework
php.iniの編集 †
include_pathにコピーしたパス「/usr/local/ZendFramework/library」を追加する。
include_path = ".:/php/includes:/usr/local/ZendFramework/library"
Apacheの再起動 †
# /etc/init.d/httpd restart
Hello Worldを出してみる †
今回は例として「/home/matsui」ディレクトリに設置します。
[[Zend Framework インストール>PHP/フレームワーク/Zend Framework##j77b6b18]]
上記の方法でインストール済みとして説明します。
ApacheのDocumentRootは「/home/matsui/public_html」です。
/home/matsui/ | |__ZendApp/ | |__controllers/ | | | | | |__HelloController.php | | | |__models/ | | | |__views/ | | | |__scripts/ | | | |__hello/ | | | |__index.phtml |__public_html/ | |__index.php |__.htaccess
public_html/index.php †
<?php require_once('Zend/Controller/Front.php'); Zend_Controller_Front::run('../ZendApp/controllers'); ?>
public_html/.htaccess †
php_flag magic_quotes_gpc off RewriteEngine on RewriteBase / RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
ZenApp/controllers/HelloController.php †
<?php require_once 'Zend/Controller/Action.php'; class HelloController extends Zend_Controller_Action { public function indexAction(){ $this->view->assign('hoge', 'Hello, World'); echo $this->render('index'); } } ?>
ZenApp/scripts/hello/index.phtml †
<html> <head> <title>Hello, World!</title> </head> <body> <h1><?php echo $this->hoge; ?></h1> <pre> ZendFrameworkのテストです。 </pre> </body> </html>
Webでアクセス †
http://[IP や VirtualName]/helo/