Php Doctrine2:ReflectionException“with message”类注释在…中不存在,同时尝试在codeigniter控制器中使用条令模型

Php Doctrine2:ReflectionException“with message”类注释在…中不存在,同时尝试在codeigniter控制器中使用条令模型,php,codeigniter,doctrine-orm,doctrine,autoload,Php,Codeigniter,Doctrine Orm,Doctrine,Autoload,我收到一条消息:class_parents:当试图在CodeIgniter控制器中使用条令模型时,类注释不存在,无法加载 这是完整的stacktrace 致命错误:未捕获的异常“ReflectionException”,在C:\Users\user\Desktop\projects\Session\application\libraries\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php:73堆栈跟踪:0C:\Us

我收到一条消息:class_parents:当试图在CodeIgniter控制器中使用条令模型时,类注释不存在,无法加载

这是完整的stacktrace 致命错误:未捕获的异常“ReflectionException”,在C:\Users\user\Desktop\projects\Session\application\libraries\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php:73堆栈跟踪:0C:\Users\user\Desktop\projects\interview\application\libraries\doctor\Common\Persistence\Mapping\RuntimeReflectionService.php73:ReflectionClass->\uu构造“Comment”1 C:\Users\user\Desktop\projects\interview\application\libraries\doctor\ORM\Mapping\ClassMetadataInfo.php769:条令\Common\Persistence\Mapping\RuntimeReflectionService->getClass'Comment'2 C:\Users\user\Desktop\projects\Session\application\libraries\条令\ORM\Mapping\ClassMetadataFactory.php591:条令\ORM\Mapping\ClassMetadataInfo->InitializeReflectionObject条令\Common\Persistence\Mapping\RuntimeReflectionService 3C:\Users\user\Desktop\projects\interview\application\libraries\doctor\ORM\Mapping\ClassMetadataFactory.php272:doctor\ORM\Mapping\ClassMetadataFactory->在第73行的C:\Users\user\Desktop\projects\interview\application\libraries\doctor\Common\Persistence\Mapping\RuntimeReflectionService.php中初始化

这是我在/application/models/Entities/Comment.php中的模型

    <?php

namespace Entities;

use Doctrine\ORM\Mapping as ORM;

/**
 * Entities\Comment
 */
class Comment
{
    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var integer $parentid
     */
    private $parentid;

    /**
     * @var integer $isactive
     */
    private $isactive;

    /**
     * @var integer $isremoved
     */
    private $isremoved;

    /**
     * @var datetime $removaldate
     */
    private $removaldate;

    /**
     * @var string $user_name
     */
    private $user_name;

    /**
     * @var string $user_email
     */
    private $user_email;

    /**
     * @var string $user_avatar
     */
    private $user_avatar;

    /**
     * @var text $comment
     */
    private $comment;

    /**
     * @var datetime $creationdate
     */
    private $creationdate;

    /**
     * @var integer $rating
     */
    private $rating;


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

    /**
     * Set parentid
     *
     * @param integer $parentid
     * @return Comment
     */
    public function setParentid($parentid)
    {
        $this->parentid = $parentid;
        return $this;
    }

    /**
     * Get parentid
     *
     * @return integer 
     */
    public function getParentid()
    {
        return $this->parentid;
    }

    /**
     * Set isactive
     *
     * @param integer $isactive
     * @return Comment
     */
    public function setIsactive($isactive)
    {
        $this->isactive = $isactive;
        return $this;
    }

    /**
     * Get isactive
     *
     * @return integer 
     */
    public function getIsactive()
    {
        return $this->isactive;
    }

    /**
     * Set isremoved
     *
     * @param integer $isremoved
     * @return Comment
     */
    public function setIsremoved($isremoved)
    {
        $this->isremoved = $isremoved;
        return $this;
    }

    /**
     * Get isremoved
     *
     * @return integer 
     */
    public function getIsremoved()
    {
        return $this->isremoved;
    }

    /**
     * Set removaldate
     *
     * @param datetime $removaldate
     * @return Comment
     */
    public function setRemovaldate($removaldate)
    {
        $this->removaldate = $removaldate;
        return $this;
    }

    /**
     * Get removaldate
     *
     * @return datetime 
     */
    public function getRemovaldate()
    {
        return $this->removaldate;
    }

    /**
     * Set user_name
     *
     * @param string $userName
     * @return Comment
     */
    public function setUserName($userName)
    {
        $this->user_name = $userName;
        return $this;
    }

    /**
     * Get user_name
     *
     * @return string 
     */
    public function getUserName()
    {
        return $this->user_name;
    }

    /**
     * Set user_email
     *
     * @param string $userEmail
     * @return Comment
     */
    public function setUserEmail($userEmail)
    {
        $this->user_email = $userEmail;
        return $this;
    }

    /**
     * Get user_email
     *
     * @return string 
     */
    public function getUserEmail()
    {
        return $this->user_email;
    }

    /**
     * Set user_avatar
     *
     * @param string $userAvatar
     * @return Comment
     */
    public function setUserAvatar($userAvatar)
    {
        $this->user_avatar = $userAvatar;
        return $this;
    }

    /**
     * Get user_avatar
     *
     * @return string 
     */
    public function getUserAvatar()
    {
        return $this->user_avatar;
    }

    /**
     * Set comment
     *
     * @param text $comment
     * @return Comment
     */
    public function setComment($comment)
    {
        $this->comment = $comment;
        return $this;
    }

    /**
     * Get comment
     *
     * @return text 
     */
    public function getComment()
    {
        return $this->comment;
    }

    /**
     * Set creationdate
     *
     * @param datetime $creationdate
     * @return Comment
     */
    public function setCreationdate($creationdate)
    {
        $this->creationdate = $creationdate;
        return $this;
    }

    /**
     * Get creationdate
     *
     * @return datetime 
     */
    public function getCreationdate()
    {
        return $this->creationdate;
    }

    /**
     * Set rating
     *
     * @param integer $rating
     * @return Comment
     */
    public function setRating($rating)
    {
        $this->rating = $rating;
        return $this;
    }

    /**
     * Get rating
     *
     * @return integer 
     */
    public function getRating()
    {
        return $this->rating;
    }
}
这是控制器的代码

<?php
require APPPATH . 'models\Entities\Comment.php';

class CommentController extends CI_Controller{
    var $em;
    function __construct() {
        parent::__construct();
        $this->em = $this->doctrine->em;
    }
    public function index()
    {
        $comment = $this->em->find('Comment', 1);
        echo $comment->user_name . '<br/>' . $comment->comment;
    }
}
这里是doctrine.php

<?php


class Doctrine
{
    // the Doctrine entity manager
    public $em = null;

    public function __construct()
    {
        // include our CodeIgniter application's database configuration
        require_once APPPATH.'config/database.php';

        // include Doctrine's fancy ClassLoader class
        require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';

        // load the Doctrine classes
        $doctrineClassLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPPATH.'libraries');
        $doctrineClassLoader->register();

        // load Symfony2 helpers
        // Don't be alarmed, this is necessary for YAML mapping files
        $symfonyClassLoader = new \Doctrine\Common\ClassLoader('Symfony', APPPATH.'libraries/Doctrine');
        $symfonyClassLoader->register();

        // load the entities
        $entityClassLoader = new \Doctrine\Common\ClassLoader('Entities', APPPATH.'models');
        $entityClassLoader->register();

        // load the proxy entities
        $proxyClassLoader = new \Doctrine\Common\ClassLoader('Proxies', APPPATH.'models');
        $proxyClassLoader->register();

        // set up the configuration
        $config = new \Doctrine\ORM\Configuration;

        if(ENVIRONMENT == 'development')
            // set up simple array caching for development mode
            $cache = new \Doctrine\Common\Cache\ArrayCache;
        else
            // set up caching with APC for production mode
            $cache = new \Doctrine\Common\Cache\ApcCache;
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);

        // set up proxy configuration
        $config->setProxyDir(APPPATH.'models/Proxies');
        $config->setProxyNamespace('Proxies');

        // auto-generate proxy classes if we are in development mode
        $config->setAutoGenerateProxyClasses(ENVIRONMENT == 'development');

        // set up annotation driver
        $yamlDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(APPPATH.'models\Mappings');
        $config->setMetadataDriverImpl($yamlDriver);

        // Database connection information
        $connectionOptions = array(
            'driver' => 'pdo_mysql',
            'user' => $db['default']['username'],
            'password' => $db['default']['password'],
            'host' => $db['default']['hostname'],
            'dbname' => $db['default']['database']
        );

        // create the EntityManager
        $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

        // store it as a member, for use in our CodeIgniter controllers.
        $this->em = $em;
    }
}

找不出哪里出了问题。我对php及其技术相当陌生。请帮忙。任何有用的想法都会受到赞赏,你总是使用字符串

这一行必须从

$comment=$this->em->find'comment',1; 到

$comment=$this->em->find'Entities\comment',1;
在字符串中,始终使用

这一行必须从

$comment=$this->em->find'comment',1; 到

$comment=$this->em->find'Entities\comment',1;