实体 class 没有得到识别!为什么?
entity class is not getting recognize ! why?
每当我尝试使用我的实体时 class 它 return 给我一个错误
所以:
Attempted to load class "test_class" from namespace "MyBundle\Entity".
您是否忘记了另一个名字的 "use" 语句space?
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;
所以当我尝试使用我的实体 class 时,它总是 return 我那个错误。
但是当我单击 "test_class()" 时,它会打开 test_class.php 文件。
这意味着名字 space 是正确的。
$tst = new test_class();
这是我的实体class --
namespace MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* test_class
*
* @ORM\Table()
* @ORM\Entity
*/
class test_class{ ....
有谁知道如何解决这个问题?
提前致谢。
@MeuhMeuh(以上评论)是对的。我只是为了格式化而将其作为答案发布。
在命名 classes 时,您应该遵循 PascalCasing 约定。没有人会强迫你,但这是一个很好的做法。
另一方面,在 class 名称中包含 _
是 特别糟糕的 因为,根据 PSR-0 标准,它被解释为DIRECTORY_SEPARATOR
(source)
每当我尝试使用我的实体时 class 它 return 给我一个错误 所以:
Attempted to load class "test_class" from namespace "MyBundle\Entity".
您是否忘记了另一个名字的 "use" 语句space?
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;
所以当我尝试使用我的实体 class 时,它总是 return 我那个错误。
但是当我单击 "test_class()" 时,它会打开 test_class.php 文件。
这意味着名字 space 是正确的。
$tst = new test_class();
这是我的实体class --
namespace MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* test_class
*
* @ORM\Table()
* @ORM\Entity
*/
class test_class{ ....
有谁知道如何解决这个问题?
提前致谢。
@MeuhMeuh(以上评论)是对的。我只是为了格式化而将其作为答案发布。
在命名 classes 时,您应该遵循 PascalCasing 约定。没有人会强迫你,但这是一个很好的做法。
另一方面,在 class 名称中包含 _
是 特别糟糕的 因为,根据 PSR-0 标准,它被解释为DIRECTORY_SEPARATOR
(source)