Zend FrameworkでSmartyを使う環境を作る [PHP]
サーバが復旧したようなので、Smartyの続きをやる。
第12回 Smartyとフレームワーク(その2:Zend Framework編)
これだけだと、何をどこにおくかよくわからなかったので。。。↓ここも参考にさせてもらった。
http://helog.jp/php/zend-framework/984/
ディレクトリ構成は下記の通りに変更。適宜index.phpのディレクトリ指定部分を修正。
htdocs(DocumentRoot)
|--- index.php
|--- [application]
|--- [controllers]
| |--- TestController.php
|--- [smarty]
| |--- [cache]
| |--- [configs]
| |--- [templates]
| | |--- [test]
| | |--- hello.tpl
| |--- [templates_c]
| |--- Zend_View_Smarty.class.php
|--- [views]
|--- [scripts]
ディレクトリ以外に、修正が必要だったのは以下の点。
(1) 以下のNOticeメッセージが出る
Notice: Zend_Loader::Zend_Loader::registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader...
index.phpを下記の通り修正
(削除)
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
(追加)
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
(2) 下記のWarningメッセージが出る
Warning: include_once(Smarty\Internal\Data.php) [function.include-once]: failed to open stream: No such file or directory
index.phpを下記の通り修正
(追加)
Zend_Loader_Autoloader::getInstance()->pushAutoloader(NULL, 'Smarty_' );
以上で、サンプルコードが無事起動。
ちなみに、起動は http://localhost/test/hello/ で行う。
コメント 0