数週間前に Doctrine と Zend Framework の Resource Bootstrapper を書き、それをすべて小さなラッパー フレームワークに変えました。ZF と Doctrine は素晴らしいチームだと思うからです。ここで記事を読むことができます:
http://coffeecoders.de/2009/06/using-the-zend-framework-18-bootstrapper-and-doctrine-110/
これは、Bootstrap リソース構成を介して完全に構成可能です (例も含まれています)。残念ながら、Doctrine はファイル名と同じクラス名 (ZF 命名スキームと一致しない) を持つモデル フォルダー内のモデルを検索するため、実際には Doctrine Autoloader の登録を取り除くことはできませんでした。リソース ローダーは次のようになります。
<?php
/**
* Doctrine model loading bootstrap resource. Options must provide a connection string.
* directory option for model directory is optional (default is ./models).
* Further options will be set for the Doctrine manager via setAttribute (e.g. model_loading).
* @author daff
*/
class Cuckoo_Application_Resource_Model extends Zend_Application_Resource_ResourceAbstract
{
public function init()
{
$manager = Doctrine_Manager::getInstance();
$options = $this->getOptions();
foreach($options as $key => $value)
{
if($key != 'connection' && $key != 'directory')
$manager->setAttribute($key, $value);
}
if(empty($options['connection']))
throw new Exception("No database connection string provided!");
Doctrine_Manager::connection($options['connection']);
if(empty($options['directory']))
$dir = './models';
else
$dir = $options['directory'];
Doctrine::loadModels(realpath($dir));
return $manager;
}
}