Php 条令和代码点火器:未找到实体

Php 条令和代码点火器:未找到实体,php,codeigniter,doctrine-orm,doctrine,Php,Codeigniter,Doctrine Orm,Doctrine,我使用的是Codeigniter 3和Doctrine 2,它们由库类加载。 条令本身是通过作曲家自动加载加载的 在localhost(WindowswithPHP5.6.0)上,我使用的是php内置服务器,一切正常。 当我将项目上传到我的Web服务器(带有nginx和代理apache的Plesk,PHP5.6.15)时,我得到以下错误: An uncaught Exception was encountered Type: Doctrine\Common\Persistence\Mappin

我使用的是Codeigniter 3和Doctrine 2,它们由库类加载。 条令本身是通过作曲家自动加载加载的

在localhost(WindowswithPHP5.6.0)上,我使用的是php内置服务器,一切正常。 当我将项目上传到我的Web服务器(带有nginx和代理apache的Plesk,PHP5.6.15)时,我得到以下错误:

An uncaught Exception was encountered

Type: Doctrine\Common\Persistence\Mapping\MappingException

Message: Class 'Entity\User' does not exist

Filename: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php    
Line Number: 96

Backtrace:

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php
Line: 41
Function: nonExistingClass

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Line: 282
Function: getParentClasses

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Line: 313
Function: getParentClasses

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Line: 78
Function: loadMetadata

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Line: 216
Function: loadMetadata

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php
Line: 281
Function: getMetadataFor

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php
Line: 44
Function: getClassMetadata

File: /var/www/vhosts/example.org/project.example.org/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php
Line: 698
Function: getRepository

File: /var/www/vhosts/example.org/project.example.org/application/controllers/User.php
Line: 18
Function: getRepository

File: /var/www/vhosts/example.org/project.example.org/index.php
Line: 301
Function: require_once
控制器如下:

....
public function show($id)
{
    $user = $this->doctrine->em->getRepository('Entity\User')->findOneBy(array('id' => $id));
}
....
以及条令图书馆: 使用条令\Common\ClassLoader, 条令\ORM\Tools\Setup, 条令\ORM\EntityManager

class Doctrine {

    public $em;
    public function __construct()
    {
        // Load the database configuration from CodeIgniter
        require APPPATH . 'config/database.php';

        $connection_options = array(
            'driver'        => 'pdo_mysql',
            'user'          => $db['default']['username'],
            'password'      => $db['default']['password'],
            'host'          => $db['default']['hostname'],
            'dbname'        => $db['default']['database'],
            'charset'       => $db['default']['char_set'],
            'driverOptions' => array(
                'charset'   => $db['default']['char_set'],
            ),
        );
        // With this configuration, your model files need to be in     application/models/Entity
        // e.g. Creating a new Entity\User loads the class from application/models/Entity/User.php
        $models_namespace = 'Entity';
        $models_path = APPPATH . 'models';
        $proxies_dir = APPPATH . 'models/proxies';
        $metadata_paths = array(APPPATH . 'models/entity');
        // Set $dev_mode to TRUE to disable caching while you develop
        $dev_mode = true;
        // If you want to use a different metadata driver, change createAnnotationMetadataConfiguration
        // to createXMLMetadataConfiguration or createYAMLMetadataConfiguration.
        $config = Setup::createAnnotationMetadataConfiguration($metadata_paths, $dev_mode, $proxies_dir);
        $this->em = EntityManager::create($connection_options, $config);
        $loader = new ClassLoader($models_namespace, $models_path);
        $loader->register();
    }

}
通过autoload.php加载库:

$autoload['libraries'] = array('OAuth2', 'session', 'doctrine');
实体位于
models\entity\

<?php
namespace Entity;
use Doctrine\ORM\Mapping\Entity;

defined('BASEPATH') OR exit('No direct script access allowed');


/**
 * User Model
 *
 * @Entity
 * @Table(name="user")
 */
class User {

    /**
     * @Id
     * @Column(type="integer", nullable=false)
     * @GeneratedValue(strategy="AUTO")
     */
     protected $id;
....

发现问题:linux区分大小写:

实体的文件夹应根据名称空间大写。由于目录是
models\entity\
,并且Windows的文件系统不区分大小写,所以它在本地工作。但是linux是区分大小写的,需要
models\Entity

将文件夹重命名为
models\Entity
,它正在工作。

发现问题:linux区分大小写:

实体的文件夹应根据名称空间大写。由于目录是
models\entity\
,并且Windows的文件系统不区分大小写,所以它在本地工作。但是linux是区分大小写的,需要
models\Entity
。 将文件夹重命名为
models\Entity
,它正在工作