2012-09-22 5 views
5

Beim Einrichten ZF2 + ODM, ich die folgende Fehlermeldung erhalten:Zend Framework 2 + Doctrine ODM, "Die Klasse wurde nicht in der Kette konfiguriert Namespaces gefunden" Fehler?

The class 'Application\Document\User' was not found in the chain configured namespaces 

Das aktuelle Setup ist wie folgt:

ZF2 stabil, ODM installiert Lehre über composer.phar mit Inhalt des Komponisten .json

{ 
    "name": "zendframework/skeleton-application", 
    "description": "Skeleton Application for ZF2", 
    "license": "BSD-3-Clause", 
    "keywords": [ 
     "framework", 
     "zf2" 
    ], 
    "homepage": "http://framework.zend.com/", 
    "minimum-stability": "dev", 
    "require": { 
     "php": ">=5.3.3", 
     "zendframework/zendframework": "2.0.0", 
     "doctrine/doctrine-mongo-odm-module": "dev-master" 
    } 
} 

Module geladen

'modules' => array(
    'Application', 
    'DoctrineModule', 
    'DoctrineMongoODMModule', 
), 

Hydrator und Proxy-dirs sind

$ ls -l data/DoctrineMongoODMModule/ 
total 0 
drwxrwxrwx 2 wisu staff 68 Sep 12 08:34 Hydrators 
drwxrwxrwx 2 wisu staff 68 Sep 12 08:35 Proxy 

die odm Config sieht erstellt wie

'driver' => array(
    'odm_default' => array(
     'drivers' => array(
      'Application\Document' => 'aplikasi' 
     ) 
    ), 
    'aplikasi' => array(
     'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver', 
     'cache' => 'array', 
     'paths' => array(
      'module/Application/src/Application/Document' 
     ) 
    ) 
), 

Ich versuche, die folgende Abbildung es

<?php 

namespace Application\Document; 

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; 

/** @ODM\Document(collection="user") */ 
class User 
{ 
    /** @ODM\Id */ 
    private $id; 

    /** @ODM\Field(type="string") */ 
    private $name; 

    /** 
    * @return the $id 
    */ 
    public function getId() { 
     return $this->id; 
    } 

    /** 
    * @return the $name 
    */ 
    public function getName() { 
     return $this->name; 
    } 

    /** 
    * @param field_type $id 
    */ 
    public function setId($id) { 
     $this->id = $id; 
    } 

    /** 
    * @param field_type $name 
    */ 
    public function setName($name) { 
     $this->name = $name; 
    } 

} 

aber über

<?php 

namespace Application\Controller; 

use Zend\Mvc\Controller\AbstractActionController; 
use Zend\View\Model\ViewModel; 
use Application\Document\User; 

class IndexController extends AbstractActionController 
{ 
    public function indexAction() 
    { 

     $dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default'); 

     $user = new User(); 
     $user->setName("Gembul"); 

     $dm->persist($user); 
     $dm->flush(); 

     return new ViewModel(); 
    } 
} 
Aufruf zu verwenden,

Beliebige po Inters?

+0

Ich glaube nicht die bereitgestellte Antwort richtig ist. Hat jemand anderes irgendwelche Gedanken darüber, was das Problem sein könnte? – Sam152

Antwort

0

das Problem Fand heraus ...

Config-Datei module.doctrine-Mongo-odm.local.php war nicht unter Autoload-Verzeichnis ...

+0

Sind Sie sicher, dass das tatsächlich die Lösung war? Ich habe das gleiche Problem mit DoctrineORMModule. Ich habe versucht, das Doku-Konfig-Array auf globaler Ebene zu setzen und es von der Modulebene aufgerufen zu haben, und ich bekomme immer den gleichen Fehler. –

3

Echt Lösung wird module.doctrine-Mongo nicht hinzugefügt -odm.local.php in Autoload-Verzeichnis, arbeitete diese Zeilen für mich als Konfiguration

'driver' => array(   
     'ODM_Driver' => array(
      'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver', 
      'paths' => array(__DIR__ . '/../../module/Application/src/Application/Doctrine/Document') 
     ), 
     'odm_default' => array(
      'drivers' => array(
       'Application\Doctrine\Document' => 'ODM_Driver' 
      ) 
     ), 
    ), 
3

Diese Installation funktioniert mit den aktuellen Versionen: ZF2, MongoDB, and Doctrine installation

Kopieren Sie die Standardkonfigurationsdatei des Odms in unser Konfigurationsverzeichnis. Sie müssen dann die Datei module.doctrine-mongo-odm.local.php entsprechend Ihren Serverspezifikationen modifizieren. Dies ist die Konfigurationsdatei, in der Sie Ihre Server-Hosts, Ports, Benutzernamen und Passwörter festlegen. Zum Beispiel nehmen wir an, dass alles auf demselben lokalen Rechner läuft und keine Änderungen vorgenommen werden.

Dies ist eine Anwendung module.config.php, die für eine Hybridlösung ORM/ODM arbeiten:

'doctrine' => array(
    'driver' => array(
     'orm_driver' => array(
      'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 
      'cache' => 'array', 
      'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') 
     ), 
     'orm_default' => array(
      'drivers' => array(
       __NAMESPACE__ . '\Entity' => 'orm_driver' 
      ) 
     ), 
     'odm_driver' => array(
      'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver',   
      'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Document') 
     ), 
     'odm_default' => array(
      'drivers' => array(
       __NAMESPACE__ . '\Document' => 'odm_driver' 
      ) 
     )     
    ) 
)