【发布时间】:2015-08-04 07:55:39
【问题描述】:
当我尝试使用我的实体类时,它会返回一个错误,例如 所以:
尝试从命名空间“MyBundle\Entity”加载类“test_class”。
您是否忘记了另一个命名空间的“使用”语句?
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerAware;
use MyBundle\Entity\test_class;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
所以当我尝试像这样使用我的实体类时,它总是返回那个错误。
但是当我单击“test_class()”时,它会打开 test_class.php 文件。
这意味着命名空间是正确的。
$tst = new test_class();
这是我的实体类 --
namespace MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* test_class
*
* @ORM\Table()
* @ORM\Entity
*/
class test_class{ ....
有谁知道如何解决这个问题?
提前致谢。
【问题讨论】:
-
你必须用大写来命名你的类。文件名应该是TestClass.php,类名应该是TestClass,而不是test_class。
-
@MeuhMeuh 非常感谢,我现在就试试...
标签: php symfony doctrine-orm entity