PHP/フレームワーク/Zend Framework の変更点


*Zend Framework [#o8f6c544]

[[dokuwiki.fl8.jp掲載済>http://dokuwiki.fl8.jp/11_php/02_framework/10_zend_framework]]

PHP本家Zendが提供する純正フレームワーク

#contents

**リファレンス [#c334f52b]
[[http://www.zendframework.com/manual/ja/manual.html>http://www.zendframework.com/manual/ja/manual.html]]

**インストール [#j77b6b18]

***ダウンロード [#ef7eb830]
[[http://framework.zend.com/download>http://framework.zend.com/download]]

&color(Blue){※無料の登録が必要です。};

今回はコレを使用しました。
-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の編集 [#jfd72d96]
include_pathにコピーしたパス「/usr/local/ZendFramework/library」を追加する。
 include_path = ".:/php/includes:/usr/local/ZendFramework/library"

***Apacheの再起動 [#wb7e64bd]
 # /etc/init.d/httpd restart


**Hello Worldを出してみる[#o70644b9]

今回は例として「/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 [#fc76c3d7]
 <?php
 require_once('Zend/Controller/Front.php');
 Zend_Controller_Front::run('../ZendApp/controllers');
 ?>

***public_html/.htaccess [#vb3e72d5]
 php_flag magic_quotes_gpc off
 
 RewriteEngine on
 RewriteBase /
 RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

***ZenApp/controllers/HelloController.php [#xa2b725f]
 <?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 [#ob556f99]
 <html>
 <head>
 <title>Hello, World!</title>
 </head>
 <body>
 <h1><?php echo $this->hoge; ?></h1>
 <pre>
 ZendFrameworkのテストです。
 </pre>
 </body>
 </html>

***Webでアクセス [#te83667b]
 http://[IP や VirtualName]/helo/