Zend_Loader_Autoloaderの追記

Zend Framework 2.0からはZend_Loader_Autoloaderですよ、という記事を書きましたが、自分で組み込んだライブラリや、Application/modelにパスを通していたファイルが自動で読み込めなくなったりしてました。
デフォルトの動作では’Zend_’や’ZendX_’というprefixのものしか自動で読み込まないとか。

れぶろぐ – [Zend] Zend_Loader_Autoloader クラスの正しい使い方

ので、パスが通っていれば自動で読み込みにいく、昔のregisterAutoloadのような設定にするには以下のようにします。

[php]
require_once ‘Zend/Loader/Autoloader.php’;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
[/php]

メモメモ。

関連する記事:

Powered by

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">