ZF2

2013-09-12 2 views
3

에서 교리 파일 매핑 드라이버를 구성하는 방법이 오류가 있습니다ZF2

Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'File mapping drivers must have a valid directory path, however the given path [path/to/my/entities] seems to be incorrect

를하고 난 내 module.config.php이 있습니다

'doctrine' => array(
    'driver' => array(
     // defines an annotation driver with two paths, and names it `my_annotation_driver` 
     'my_annotation_driver' => array(
      'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 
      'cache' => 'array', 
      'paths' => array(
       __DIR__ . '/../src/Realez/Entity', 
       'another/path' 
      ), 
     ), 

     // default metadata driver, aggregates all other drivers into a single one. 
     // Override `orm_default` only if you know what you're doing 
     'orm_default' => array(
      'drivers' => array(
       // register `my_annotation_driver` for any entity under namespace `My\Namespace` 
       'Realez/Entity' => 'my_annotation_driver' 
      ) 
     ) 
    ) 
) 

답변

1

이 module.config.php 수정 파일.

return array(
    'doctrine' => array(
     'driver' => array(
      __NAMESPACE__.'_driver' => array(
       'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 
       'cache' => 'array', 
       'paths' => array(__DIR__ . '/../src/'.__NAMESPACE__.'/Entity') 
      ), 
      'orm_default' => array(
       'drivers' => array(
        __NAMESPACE__'\Entity' => __NAMESPACE__.'_driver' 
       ), 
      ), 
     ), 
    ),     
); 
+0

이 내 module.config.php 파일이 무엇인지 정확히 내가 여전히 같은 오류로 받고 있어요 OP – Scott

+0

나 같은 일. 어떻게 문제를 해결 했습니까? –

+0

이것은 나를 위해 일했습니다. 감사. –

6

나는 정확히 같은 문제가있었습니다. Doctrine이 내 엔터티를 저장할 위치에 빈 Entity 디렉터리를 만들어서 해결했습니다. 다음 위치에 빈 Entity 디렉토리 (즉, __DIR__ . '/../src/Realez/Entity')를 생성하기 만하면됩니다.

1
**File mapping drivers must have a valid directory path, however the given path [path/to/my/entities]** 

이것은 당신이

당신은 당신의 paths가 올바른지 확인 해당 위치

0

에 하나를 만들 필요가있는 디렉토리에서 법인 폴더가없는 것을 의미한다.

  __NAMESPACE__ . '_driver' => [ 
       'class' => AnnotationDriver::class, 
       'cache' => 'array', 
       'paths' => [__DIR__ . '/../src/Entity/'], 
// or:    'paths' => [__DIR__ . '/../src/Entity/'.__NAMESPACE__.'/Entity'] 

      ], 
      'orm_default' => [ 
       'drivers' => [ 
        __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' 
       ] 
      ], 

은 또한 당신은 교리 명령 행 도구를 사용하여 메타 데이터 캐시를 삭제하려고 할 수 있습니다 :

./doctrine-module orm:clear-cache:metadata