比斯纳主义2.1& 2.2注释“@Table”从未导入过

时间:2012-03-11 12:31:18

标签: php zend-framework doctrine

我习惯使用zend mvc以及与bisna驱动程序绑定的doctrine 2.1和2.2。

对于新项目,我正在使用注释驱动程序只是为了方便(我喜欢)。如何从数据库生成我的实体并尝试加载它们但是它们不断产生错误:

[Semantical Error] The annotation "@Table" in class MyWheels\Entity\Bmulog was never imported.

我尝试向他们添加ORM \前缀,但这并没有解决它。

我的配置文件读取:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"

pluginPaths.Bisna\Application\Resource\ = "Bisna/Application/Resource"
autoloaderNamespaces[] = Bisna
autoloaderNamespaces[] = Doctrine
autoloaderNamespaces[] = MyWheels
autoloaderNamespaces[] = Symfony

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

resources.doctrine.cache.instances.default.namespace    = "Application_"
resources.doctrine.dbal.connections.default.parameters.dbname   = "mywheels"
resources.doctrine.dbal.connections.default.parameters.user = "root"
resources.doctrine.dbal.connections.default.parameters.password = ""
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.adapterClass = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingNamespace = "MyWheels\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingDirs[] = APPLICATION_PATH "\..\library\MyWheels\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader" 

任何人都知道这里出了什么问题?

我的实体代码是:

<?php

namespace MyWheels\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * MyWheels\Entity\Bmulog
 *
 * @Table(name="bmulog")
 * @Entity
 */
class Bmulog
{
    /**
     * @var integer $id
     *
     * @Column(name="id", type="integer", nullable=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var text $request
     *
     * @Column(name="request", type="text", nullable=false)
     */
    private $request;

    /**
     * @var text $responce
     *
     * @Column(name="responce", type="text", nullable=false)
     */
    private $responce;

    /**
     * @var string $ip
     *
     * @Column(name="ip", type="string", length=200, nullable=false)
     */
    private $ip;

    /**
     * @var string $browser
     *
     * @Column(name="browser", type="string", length=200, nullable=false)
     */
    private $browser;

    /**
     * @var datetime $date
     *
     * @Column(name="date", type="datetime", nullable=false)
     */
    private $date;


}

Doctrine 2.2.0导致大致相同的错误:

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Table" in class MyWheels\Entity\Bmulog does not exist, or could not be auto-loaded.

1 个答案:

答案 0 :(得分:5)

使用Doctrine\ORM\Mapping意味着将导入别名添加为Doctrine注释标记的前缀。

@ORM\Table
@ORM\Entity
@ORM\Column
@ORM\... (Any Doctrine annotation)