Reputation: 1496
i have a quite primitve problem:
I created an Entity in my Symfony App:
src/AppBundle/Model/Article/Article.php:
<?php
namespace AppBundle\Model\Article;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="articles")
*/
class Article {
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length="255", nullable=false)
*/
private $name;
}
When i type in console:
php app/console doctrine:generate:entities AppBundle
it prints:
Bundle "AppBundle" does not contain any mapped entities.
And when i type:
php app/console doctrine:generate:entities AppBundle/Model/Article/Article
it prints:
Class "AppBundle\Model\Article\Article" is not a valid entity or mapped super class.
Anybody has some idea how to solve this?
I already followed some solutions on stackoverflow like changing or turning off cache/clearing cache/ etc.. but none works.
Thanks and Greetings!
Upvotes: 0
Views: 3615
Reputation: 2698
You need to make sure that you do not use Doctrine\Common\Annotations\SimpleAnnotationReader
class. Instead Doctrine\Common\Annotations\AnnotationReader
should be used.
Simple reader doesn't support @ORM\Annotation
, only @Annotation
.
Upvotes: 0
Reputation: 239
You should add all your Entities in the Entity Folder, remember Entity and Model are different concepts. You can create others folders like Model, Handlers, Managers. Another important thing is not to confuse Data Base with Object-oriented programming.
Upvotes: 0
Reputation: 1280
Probably Doctrine doesn't know about these mappings. Have you created this bundle with a generator?
Check your config.yml
in app/config, you should have an entry under following keys structure:
doctrine:
orm:
mappings:
AppBundle: ~
Edit: Ok, you use custom structure. Default namespace should look like that:
AppBundle\Entity
So full class name should be AppBundle\Entity\Article
If you want to stick with custom mappings, check configuration docs.
Upvotes: 6