如何在Bisna中正确加载DoctrineExtensions?

时间:2011-10-16 17:04:42

标签: php zend-framework doctrine-orm

我正在尝试加载一些学说扩展,但我得到了各种错误。到目前为止,这就是我所拥有的

在我的ini:

autoloaderNamespaces[] = "DoctrineExtensions"
resources.doctrine.classLoader.loaderClass = "Doctrine\Common\ClassLoader"
resources.doctrine.classLoader.loaderFile  = "Doctrine/Common/ClassLoader.php"

resources.doctrine.classLoader.loaders.DoctrineExtensions_Paginate.namespace = "DoctrineExtensions\Paginate"
resources.doctrine.classLoader.loaders.DoctrineExtensions_Paginate.includePath = APPLICATION_PATH '/../library/Doctrine/DoctrineExtensions/Paginate/'

在我的一个控制器中:

  $count = Paginate::getTotalQueryResults($query); // Step 1
  $paginateQuery = Paginate::getPaginateQuery($query, $offset, $limitPerPage); // Step 2 and 3
  $result = $paginateQuery->getResult();

这就是错误:

  

警告:include_once(DoctrineExtensions / Paginate.php):无法打开流:没有这样的文件或目录

2 个答案:

答案 0 :(得分:3)

我建议你试试这个插件:beberlei / DoctrineExtensions

以下是有关如何将其集成到项目中的详细信息:README

我不认为你可以这样做,因为开发人员已经构建了扩展! :S

为了对班级Paginate使用自动加载,该类应该被称为DoctrineExtensions_Paginate_Paginate

祝你好运!

答案 1 :(得分:3)

尝试简单的事情

 //include class loader first

 //make sure this is correct
 $doctrine_root=APPLICATION_PATH. '/../library/Doctrine';

 require_once $doctrine_root.'/Common/ClassLoader.php';

 $classLoader = new \Doctrine\Common\ClassLoader('Doctrine',$doctrine_root);

 $classLoader->register();

 user Doctrine\DoctrineExtensions\Paginate;

然后尝试重置代码

  $count = Paginate::getTotalQueryResults($query); // Step 1
  // Step 2 and 3
  $paginateQuery = Paginate::getPaginateQuery($query, $offset, $limitPerPage);  

  $result = $paginateQuery->getResult();

让我知道这是如何运作的

欢呼:)

注意:我没有在最后测试此代码