Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Doctrine doctrine:generate:entities never works

I am relatively new to Symfony2 and so far love it - except for this problem that I keep coming up against.

The dreaded (for me): doctrine:generate:entities

When I started my first Symfony2 project I could not get that command working and ended up just using doctrine:generate:entity instead which worked fine.

However, this time I am trying to write an application for a system that already has database tables. I followed the instructions at: Symfony2 Docs which seemed to all work fine except, as usual for the doctrine:generate:entities bit.

I have the following Entity file @ My/Bundle/FeedManagerBundle/Entity/Feeds.php

<?php

namespace My\Bundle\FeedManagerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Feeds
 *
 * @ORM\Table(name="feeds")
 * @ORM\Entity
 */
class Feeds
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="feed_label", type="string", length=100, nullable=false)
     */
    private $feedLabel;

    /**
     * @var integer
     *
     * @ORM\Column(name="advertiser_id", type="integer", nullable=false)
     */
    private $advertiserId;

    /**
     * @var boolean
     *
     * @ORM\Column(name="active", type="boolean", nullable=false)
     */
    private $active;


}

And in My/Bundle/FeedManagerBundle/Resources/config/doctrine/Feeds.orm.yml

Feeds:
    type: entity
    table: feeds
    fields:
    id:
        id: true
        type: integer
        unsigned: false
        nullable: false
        generator:
            strategy: IDENTITY
    feedLabel:
        type: string
        length: 100
        fixed: false
        nullable: false
        column: feed_label
    advertiserId:
        type: integer
        unsigned: false
        nullable: false
        column: advertiser_id
    active:
        type: boolean
        nullable: false
    lifecycleCallbacks: {  }

And this is the error I am getting:

$ php app/console doctrine:generate:entities My/Bundle/FeedManagerBundle/Entity/Feeds --path=src
Generating entity "My\Bundle\FeedManagerBundle\Entity\Feeds"



  [Doctrine\Common\Persistence\Mapping\MappingException]                                                                         
  Invalid mapping file 'My.Bundle.FeedManagerBundle.Entity.Feeds.orm.yml' for class 'My\Bundle\FeedManagerBundle\Entity\Feeds'.  



doctrine:generate:entities [--path="..."] [--no-backup] name

I have tried changing the name of the yml file to the full path. I have also tried changing the first line of the yml file to the full path and I have tried doing both of those things at the same time. Nothing seems to work & now I am getting to pulling my hair out stage. Can anyone think of any reason why this might not be working?

like image 452
someuser Avatar asked Feb 27 '13 16:02

someuser


1 Answers

Change Feed.orm.yml to:

My\Bundle\FeedManagerBundle\Entity\Feeds:
   type: entity
   table: feeds
   ...
like image 67
seferov Avatar answered Sep 21 '22 21:09

seferov