laravel-doctrine icon indicating copy to clipboard operation
laravel-doctrine copied to clipboard

Metadata Configuration with chainning

Open josenicomaia opened this issue 9 years ago • 6 comments

When using metadata with chainning, configured in /config/doctine.php, the Entities (with annotation) is not reconized.

'metadata' => [
        'driver' => 'config',
        [
            'driver' => 'config'
        ],
        [
            'driver' => 'annotation'
        //    'namespace' => 'App'
        //    'alias' => 'DoctrineModel'
        ],
        [
            'driver' => 'yaml',
        ],
        [
            'driver' => 'xml'
        ],
        [
            'driver' => 'static'
        ]
]

I can use annotations entities, but i need to set to:

'metadata' => [
        [
            'driver' => 'annotation'
        ]
]

PS: I am using with Laravel 5.1

josenicomaia avatar Jun 18 '15 17:06 josenicomaia

I think i am having the same issue... It keeps saying me that "No identifier/primary key specified for Entity "App\Test". Every Entity must have an identifier/primary key.", although the annotations are there!

I already tried the config you mentioned, but it didnt work for me.

Also Laravel 5.1.

danilomendes avatar Jun 24 '15 14:06 danilomendes

Could you post your Model?

josenicomaia avatar Jun 24 '15 14:06 josenicomaia

no big deal... just playing around.


namespace App;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="tests")
 * @ORM\HasLifecycleCallbacks()
 */
class Test {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     */
    protected $email;

    // getters & setters

}

danilomendes avatar Jun 24 '15 14:06 danilomendes

I am doing like this:

doctrine.php:

    'metadata' => [
        [
            'driver' => 'annotation',
            'namespace' => 'App'
        ]
    ]

Model:

    /**
     *
     * @var int
     * @ORM\Id
     * @ORM\Column(name="dummy_id", type="integer", unique=true, nullable=false)
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

Did you tried to run "vendor\bin\doctrine orm:info"?

josenicomaia avatar Jun 24 '15 14:06 josenicomaia

sorry, i was editing the package's doctrine.php file.

thank you for your help! :)

danilomendes avatar Jun 24 '15 15:06 danilomendes

Relax! It happens =P

You're welcome!

josenicomaia avatar Jun 24 '15 15:06 josenicomaia