Я пытаюсь интегрировать mongoDB с Zend Framework и Doctrine.До сих пор интеграция работала хорошо.Единственная проблема, с которой я столкнулся, заключается в том, что мои сущности не были найдены (что соответствует полученному сообщению об ошибке).
Ошибка:
Warning: class_parents() [function.class-parents]: Class User does not exist and could not be loaded in /Applications/XAMPP/xamppfiles/htdocs/project/library/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336
Warning: array_reverse() expects parameter 1 to be array, boolean given in /Applications/XAMPP/xamppfiles/htdocs/project/library/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336
Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/project/library/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336
Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in /Applications/XAMPP/xamppfiles/htdocs/project/library/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php, line 336' in /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Controller/Response/Abstract.php:323 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Controller/Response/Abstract.php(341): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Controller/Response/Abstract.php(768): Zend_Controller_Response_Abstract->sendHeaders() #2 /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Controller/Front.php(992): Zend_Controller_Response_Abstract->sendResponse() #3 /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #4 /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Application.php(366): Zend_Applic in /Applications/XAMPP/xamppfiles/htdocs/project/library/Zend/Controller/Response/Abstract.php on line 323
Мой application.ini:
[production]
; PHP settings
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
; Set Plugin path for Lupi mongoodm resource
pluginPaths.Lupi_Resource = APPLICATION_PATH "/../Library/Lupi/Resource"
; Library include paths & namespaces
includePaths.library = APPLICATION_PATH "/../library"
autoloaderNamespaces[] = "Lupi\"
autoloaderNamespaces[] = "Doctrine\"
autoloaderNamespaces[] = "Symfony\"
; Bootstrap options
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
; Applicaiton Setup
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
; ODM settings
resources.odm.documents.dir = APPLICATION_PATH "/models/Entities"
resources.odm.documents.namespace = "Application"
resources.odm.config.proxyDir = APPLICATION_PATH "/models/Proxies"
resources.odm.config.proxyNamespace = "proxies"
resources.odm.config.hydratorDir = APPLICATION_PATH "/models/Hydrators"
resources.odm.config.hydratorNamespace = "hydrators"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Мой Bootstrap.php пуст.Кроме того, у меня есть контроллер действий и ресурс из примера на github.
My User.php:
<?php
namespace Entities;
/**
* @Document(collection="users")
*/
class User {
/**
* @Id
*/
private $id;
/**
* @String
*/
private $username;
/**
* @String
*/
private $email;
Мой контроллер:
<?php
class RegistrationController extends Lupi\Controller\Action {
/**
* @var \Doctrine\ODM\MongoDB\DocumentRepository
*/
protected $repository;
public function init() {
$this->repository = $this->dm->getRepository('User');
}
Мой примерна основе этого здесь: http://github.com/bittarman/zf-d2-odm, презентацию по этому вопросу можно найти здесь http://www.zend.com/en/webinar/Framework/70170000000bZ6y-Doctrine2-ODM-ZF-20110526.flv,, но также и на слайд-шоу с соответствующими тегами.
Заранее спасибо за вашу помощь!=)