我开始在 silex 中使用带有来自文档的简单注释的学说@Entity并且它起作用了。现在我看到 symfony 使用 importuse Doctrine\ORM\Mapping as ORM;和@ORM\Entity. 但是当我添加这个时,学说会抛出一个错误 Class "App\Entity\Author" is not a valid entity or mapped super class.
namespace App\Entity;
use App\Helpers\Jsonable;
use App\Helpers\MassAssignable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\AuthorRepository")
* @ORM\Table(name="authors")
*/
class Author
{
use MassAssignable;
use Jsonable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @var int
*/
protected $id;
/**
* @ORM\Column(type="string")
* @var string
*/
protected $name;
我的配置没有额外的选项
$config = Setup::createAnnotationMetadataConfiguration([
__DIR__.'/../src/Entity/'
]);
$app['db.em'] = EntityManager::create($app['db'], $config);
浮云间