Symfony2 class_parents()类不存在错误

时间:2012-11-16 09:10:35

标签: php symfony orm doctrine

我正在尝试从Symfony2应用程序中的Doctrine 2表中获取数据。在我的开发机器上运行的代码在部署到生产服务器时会引发错误。这是我的一个控制器。

public function listEntitiesAction($entity, Request $request)
{       
    $repository = $this->getDoctrine()->getRepository('AALCOInventoryBundle:' . $entity);
    $metadata = $this->getDoctrine()->getEntityManager()->getClassMetadata('AALCOInventoryBundle:' . $entity);
    $dataTable = new Datatable( $request->query->all(), $repository, $metadata, $this->getDoctrine()->getEntityManager());  
    $dataTable->makeSearch();   
    $view = $this->view($dataTable->getSearchResults(), 200)
            ->setFormat('json');
    return $this->get('fos_rest.view_handler')->handle($view);
}

上面的代码适用于我本地开发机器中的linux服务器。其中一个实体如下。

<?php
namespace AALCO\InventoryBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
 * AALCO\InventoryBundle\Entity\Uom
 *
 * @ORM\Table(name="uoms")
 * @ORM\Entity
 */
class Uom
{
    // entity stuff
}

我在config.yml上有doctrine的默认设置,这是错误。

request: ErrorException: Warning: class_parents() [<a href='function.class-parents'>function.class-parents</a>]: Class AALCO\InventoryBundle\Entity\uom does not exist and could not be loaded in 
/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40 (uncaught exception) at 
/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40

为所有实体运行php app/console doctrine:mapping:info会返回OK。我已经检查了SO上的其他答案,因为这类错误并没有与我的具体问题相符。

1 个答案:

答案 0 :(得分:2)

Symfony2使用自动加载来加载带有类的文件。当你要求uow类时,它会查找uow.php文件。文件名在Linux服务器上区分大小写,因此uow.php和Uow.php是不同的文件。

您需要在ucfirst上添加某种地图或使用$entity功能。

相关问题