<bdo id='iUi9W'></bdo><ul id='iUi9W'></ul>

    1. <i id='iUi9W'><tr id='iUi9W'><dt id='iUi9W'><q id='iUi9W'><span id='iUi9W'><b id='iUi9W'><form id='iUi9W'><ins id='iUi9W'></ins><ul id='iUi9W'></ul><sub id='iUi9W'></sub></form><legend id='iUi9W'></legend><bdo id='iUi9W'><pre id='iUi9W'><center id='iUi9W'></center></pre></bdo></b><th id='iUi9W'></th></span></q></dt></tr></i><div id='iUi9W'><tfoot id='iUi9W'></tfoot><dl id='iUi9W'><fieldset id='iUi9W'></fieldset></dl></div>

      <small id='iUi9W'></small><noframes id='iUi9W'>

      <tfoot id='iUi9W'></tfoot>

    2. <legend id='iUi9W'><style id='iUi9W'><dir id='iUi9W'><q id='iUi9W'></q></dir></style></legend>

      Doctrine2 - “类"不是有效的实体或映射的超类

      Doctrine2 - quot;classquot; is not a valid entity or mapped super class(Doctrine2 - “类不是有效的实体或映射的超类)
      <legend id='LTo13'><style id='LTo13'><dir id='LTo13'><q id='LTo13'></q></dir></style></legend>
      <i id='LTo13'><tr id='LTo13'><dt id='LTo13'><q id='LTo13'><span id='LTo13'><b id='LTo13'><form id='LTo13'><ins id='LTo13'></ins><ul id='LTo13'></ul><sub id='LTo13'></sub></form><legend id='LTo13'></legend><bdo id='LTo13'><pre id='LTo13'><center id='LTo13'></center></pre></bdo></b><th id='LTo13'></th></span></q></dt></tr></i><div id='LTo13'><tfoot id='LTo13'></tfoot><dl id='LTo13'><fieldset id='LTo13'></fieldset></dl></div>
          <tbody id='LTo13'></tbody>

            • <small id='LTo13'></small><noframes id='LTo13'>

              <tfoot id='LTo13'></tfoot>

                <bdo id='LTo13'></bdo><ul id='LTo13'></ul>
              • 本文介绍了Doctrine2 - “类"不是有效的实体或映射的超类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                每次运行下一个代码时,我都会收到异常 未捕获的异常 'DoctrineORMMappingMappingException',消息为 'Class "Users" is not a valid entity or mapping super class:

                I get exception Uncaught exception 'DoctrineORMMappingMappingException' with message 'Class "Users" is not a valid entity or mapped super class every time when I run the next code:

                test.php

                <?php
                require_once "vendor/autoload.php";
                
                use DoctrineORMToolsSetup;
                use DoctrineORMEntityManager;
                
                $paths = array(dirname(__FILE__)."/entities");
                $isDevMode = false;
                
                // the connection configuration
                $dbParams = array(
                    'driver'   => 'pdo_mysql',
                    'user'     => 'root',
                    'password' => 'pass',
                    'dbname'   => 'snabcentr',
                );
                
                $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
                $em = EntityManager::create($dbParams, $config);
                
                $user = $em->find("Users", 5);
                

                entities/Users.php

                <?php
                use DoctrineORMMapping as ORM;
                
                /**
                 * Users
                 *
                 * @ORMTable(name="users")
                 * @ORMEntity
                 */
                class Users
                {
                    /**
                     * @var integer
                     *
                     * @ORMColumn(name="id", type="integer", nullable=false)
                     * @ORMId
                     * @ORMGeneratedValue(strategy="IDENTITY")
                     */
                    private $id;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="email", type="string", length=255, nullable=true)
                     */
                    private $email;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="password", type="string", length=255, nullable=true)
                     */
                    private $password;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="type", type="string", nullable=true)
                     */
                    private $type;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_inn", type="string", length=255, nullable=true)
                     */
                    private $clientInn;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_ogrn", type="string", length=255, nullable=true)
                     */
                    private $clientOgrn;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_rs", type="string", length=255, nullable=true)
                     */
                    private $clientRs;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_ks", type="string", length=255, nullable=true)
                     */
                    private $clientKs;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_bik", type="string", length=255, nullable=true)
                     */
                    private $clientBik;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_uaddress", type="string", length=255, nullable=true)
                     */
                    private $clientUaddress;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_faddress", type="string", length=255, nullable=true)
                     */
                    private $clientFaddress;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="client_daddress", type="string", length=255, nullable=true)
                     */
                    private $clientDaddress;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="name", type="string", length=255, nullable=true)
                     */
                    private $name;
                
                    /**
                     * @var string
                     *
                     * @ORMColumn(name="notes", type="text", nullable=true)
                     */
                    private $notes;
                
                    /**
                     * @var DateTime
                     *
                     * @ORMColumn(name="added_date", type="datetime", nullable=true)
                     */
                    private $addedDate;
                
                
                    /**
                     * Get id
                     *
                     * @return integer 
                     */
                    public function getId()
                    {
                        return $this->id;
                    }
                
                    /**
                     * Set email
                     *
                     * @param string $email
                     * @return Users
                     */
                    public function setEmail($email)
                    {
                        $this->email = $email;
                
                        return $this;
                    }
                
                    /**
                     * Get email
                     *
                     * @return string 
                     */
                    public function getEmail()
                    {
                        return $this->email;
                    }
                
                    /**
                     * Set password
                     *
                     * @param string $password
                     * @return SnabUsers
                     */
                    public function setPassword($password)
                    {
                        $this->password = $password;
                
                        return $this;
                    }
                
                    /**
                     * Get password
                     *
                     * @return string 
                     */
                    public function getPassword()
                    {
                        return $this->password;
                    }
                
                    /**
                     * Set type
                     *
                     * @param string $type
                     * @return SnabUsers
                     */
                    public function setType($type)
                    {
                        $this->type = $type;
                
                        return $this;
                    }
                
                    /**
                     * Get type
                     *
                     * @return string 
                     */
                    public function getType()
                    {
                        return $this->type;
                    }
                
                    /**
                     * Set clientInn
                     *
                     * @param string $clientInn
                     * @return SnabUsers
                     */
                    public function setClientInn($clientInn)
                    {
                        $this->clientInn = $clientInn;
                
                        return $this;
                    }
                
                    /**
                     * Get clientInn
                     *
                     * @return string 
                     */
                    public function getClientInn()
                    {
                        return $this->clientInn;
                    }
                
                    /**
                     * Set clientOgrn
                     *
                     * @param string $clientOgrn
                     * @return SnabUsers
                     */
                    public function setClientOgrn($clientOgrn)
                    {
                        $this->clientOgrn = $clientOgrn;
                
                        return $this;
                    }
                
                    /**
                     * Get clientOgrn
                     *
                     * @return string 
                     */
                    public function getClientOgrn()
                    {
                        return $this->clientOgrn;
                    }
                
                    /**
                     * Set clientRs
                     *
                     * @param string $clientRs
                     * @return SnabUsers
                     */
                    public function setClientRs($clientRs)
                    {
                        $this->clientRs = $clientRs;
                
                        return $this;
                    }
                
                    /**
                     * Get clientRs
                     *
                     * @return string 
                     */
                    public function getClientRs()
                    {
                        return $this->clientRs;
                    }
                
                    /**
                     * Set clientKs
                     *
                     * @param string $clientKs
                     * @return SnabUsers
                     */
                    public function setClientKs($clientKs)
                    {
                        $this->clientKs = $clientKs;
                
                        return $this;
                    }
                
                    /**
                     * Get clientKs
                     *
                     * @return string 
                     */
                    public function getClientKs()
                    {
                        return $this->clientKs;
                    }
                
                    /**
                     * Set clientBik
                     *
                     * @param string $clientBik
                     * @return SnabUsers
                     */
                    public function setClientBik($clientBik)
                    {
                        $this->clientBik = $clientBik;
                
                        return $this;
                    }
                
                    /**
                     * Get clientBik
                     *
                     * @return string 
                     */
                    public function getClientBik()
                    {
                        return $this->clientBik;
                    }
                
                    /**
                     * Set clientUaddress
                     *
                     * @param string $clientUaddress
                     * @return SnabUsers
                     */
                    public function setClientUaddress($clientUaddress)
                    {
                        $this->clientUaddress = $clientUaddress;
                
                        return $this;
                    }
                
                    /**
                     * Get clientUaddress
                     *
                     * @return string 
                     */
                    public function getClientUaddress()
                    {
                        return $this->clientUaddress;
                    }
                
                    /**
                     * Set clientFaddress
                     *
                     * @param string $clientFaddress
                     * @return SnabUsers
                     */
                    public function setClientFaddress($clientFaddress)
                    {
                        $this->clientFaddress = $clientFaddress;
                
                        return $this;
                    }
                
                    /**
                     * Get clientFaddress
                     *
                     * @return string 
                     */
                    public function getClientFaddress()
                    {
                        return $this->clientFaddress;
                    }
                
                    /**
                     * Set clientDaddress
                     *
                     * @param string $clientDaddress
                     * @return SnabUsers
                     */
                    public function setClientDaddress($clientDaddress)
                    {
                        $this->clientDaddress = $clientDaddress;
                
                        return $this;
                    }
                
                    /**
                     * Get clientDaddress
                     *
                     * @return string 
                     */
                    public function getClientDaddress()
                    {
                        return $this->clientDaddress;
                    }
                
                    /**
                     * Set name
                     *
                     * @param string $name
                     * @return SnabUsers
                     */
                    public function setName($name)
                    {
                        $this->name = $name;
                
                        return $this;
                    }
                
                    /**
                     * Get name
                     *
                     * @return string 
                     */
                    public function getName()
                    {
                        return $this->name;
                    }
                
                    /**
                     * Set notes
                     *
                     * @param string $notes
                     * @return SnabUsers
                     */
                    public function setNotes($notes)
                    {
                        $this->notes = $notes;
                
                        return $this;
                    }
                
                    /**
                     * Get notes
                     *
                     * @return string 
                     */
                    public function getNotes()
                    {
                        return $this->notes;
                    }
                
                    /**
                     * Set addedDate
                     *
                     * @param DateTime $addedDate
                     * @return SnabUsers
                     */
                    public function setAddedDate($addedDate)
                    {
                        $this->addedDate = $addedDate;
                
                        return $this;
                    }
                
                    /**
                     * Get addedDate
                     *
                     * @return DateTime 
                     */
                    public function getAddedDate()
                    {
                        return $this->addedDate;
                    }
                }
                

                你有什么想法吗?未设置 eAccelerator.Doctrine v 2.2,PHP v 5.3.22,zend 引擎 2.3.0

                Do you have any ideas why? eAccelerator is not set up. Doctrine v 2.2, PHP v 5.3.22, zend engine 2.3.0

                推荐答案

                您正在使用 DoctrineCommonAnnotationsSimpleAnnotationReader 而不是 DoctrineCommonAnnotationsAnnotationReader代码>.

                You are using a DoctrineCommonAnnotationsSimpleAnnotationReader instead of a DoctrineCommonAnnotationsAnnotationReader.

                SimpleAnnotationReader 使用默认命名空间并以 @Entity 格式读取注释,而 AnnotationReader 可以使用导入的类和命名空间(通过use 语句) 和注释,例如 @ORMEntity.

                The SimpleAnnotationReader works with default namespaces and reads annotations in format @Entity, while the AnnotationReader can use the imported classes and namespaces (via use statement) and annotations such as @ORMEntity.

                您可以在文档中阅读更多相关信息.

                You can read more about that on the documentation.

                这是您的 test.php

                <?php
                
                use DoctrineORMToolsSetup;
                use DoctrineORMEntityManager;
                use DoctrineORMMappingDriverAnnotationDriver;
                use DoctrineCommonAnnotationsAnnotationReader;
                use DoctrineCommonAnnotationsAnnotationRegistry;
                
                require_once __DIR__ . '/vendor/autoload.php';
                require_once __DIR__ . '/entities/Users.php';
                
                $paths            = array(__DIR__ . '/entities');
                $isDevMode        = false;
                $connectionParams = array(
                    'driver'   => 'pdo_mysql',
                    'user'     => 'root',
                    'password' => 'pass',
                    'dbname'   => 'dbname',
                );
                
                $config = Setup::createConfiguration($isDevMode);
                $driver = new AnnotationDriver(new AnnotationReader(), $paths);
                
                // registering noop annotation autoloader - allow all annotations by default
                AnnotationRegistry::registerLoader('class_exists');
                $config->setMetadataDriverImpl($driver);
                
                $em = EntityManager::create($connectionParams, $config);
                
                $user = $em->find('Users', 5);
                

                这篇关于Doctrine2 - “类"不是有效的实体或映射的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                How to parse django style template tags(如何解析 django 样式模板标签)
                What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                php in background exec() function(php 后台 exec() 函数)
                1. <i id='Mm41m'><tr id='Mm41m'><dt id='Mm41m'><q id='Mm41m'><span id='Mm41m'><b id='Mm41m'><form id='Mm41m'><ins id='Mm41m'></ins><ul id='Mm41m'></ul><sub id='Mm41m'></sub></form><legend id='Mm41m'></legend><bdo id='Mm41m'><pre id='Mm41m'><center id='Mm41m'></center></pre></bdo></b><th id='Mm41m'></th></span></q></dt></tr></i><div id='Mm41m'><tfoot id='Mm41m'></tfoot><dl id='Mm41m'><fieldset id='Mm41m'></fieldset></dl></div>
                    <bdo id='Mm41m'></bdo><ul id='Mm41m'></ul>
                      <tbody id='Mm41m'></tbody>

                      <legend id='Mm41m'><style id='Mm41m'><dir id='Mm41m'><q id='Mm41m'></q></dir></style></legend>

                      <small id='Mm41m'></small><noframes id='Mm41m'>

                      • <tfoot id='Mm41m'></tfoot>