0

I'm following this Symfony2/Doctrine guide and I've come to the part where I need to create getters/setters. but I am stuck with this part:

$ php app/console doctrine:generate:entities Acme/StoreBundle/Entity/Job

I've searched the net for possible solutions (seems to mainly revolve around using 2 asterisks for the start) but couldn't find the solution.

Some info:

  1. Bundle is properly loaded (via AppKernel.php) as I have a test "hello world" and that works.
  2. The namespace path is correct
  3. Job.php exists in the right folder
  4. I'm using postgres as my database. I'm not sure if this matters.
  5. I have tried with and without the use Doctrine\ORM\Mapping line in model class (see below for code)
  6. I don't think I'm running a accelerator at least according to get_loaded_extensions function Any ideas would be very helpful.

Thanks a lot :)

snippet of my settings.yml

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

Model class

<?php

// src/MyApp/MyBundle/Model/Job.php

namespace MyApp\MyBundle\Model;

use Doctrine\ORM\Mapping as ORM;

/**
 * MyApp\MyBundle\Model\Job
 *
 * @ORM\Entity
 * @ORM\Table(name="myschema.jobs")
 */
class Job {
    /**
     * @ORM\Column(name="job_id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $jobid;

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

    /**
     * @ORM\Column(name="job_desc", type="text")
     */
    protected $description;

    /**
     * @ORM\Column(name="personal_req", type="text")
     */
    protected $requirements;
}
A.L
  • 10,259
  • 10
  • 67
  • 98
mrjayviper
  • 149
  • 3
  • 12

2 Answers2

1

did you create your entity using doctrine? I saw on your Job.php entity you are using annotation as mapping format.

In error output it said doctrine can't find any mapped entities. I've been there and it solved with specific configuration of your config.yml.

Try to change this on your config.yml

doctrine:
dbal:
    driver:   "%database_driver%"
    #etc

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: false
    mappings:
        MyAppMyBundle:
            type: annotation #On your case it should be annotation
            dir: Resources/Model/

Read this maybe it can help:

Doctrine Mapping in Symfony2 using YAML

Community
  • 1
  • 1
Ivancodescratch
  • 405
  • 4
  • 14
0

Have you tried using following console command ?

$ php app/console doctrine:generate:entities MyApp/MyBundle/Model

I hope it will work. Your entity namespace is different than Acme/StoreBundle/Entity/Product. Your entities are in Model directory/namespace so you should use first argument of command a valid namespace. So that following cmd generates error as you have mentioned above.

$ php app/console doctrine:generate:entities Acme/StoreBundle/Entity/Product

kuldipem
  • 1,719
  • 1
  • 19
  • 32
  • apologies. copy/paste error in the php app/console command. I copied it straight from the link provided. But be assured I used the right one when I ran it. :) – mrjayviper Oct 02 '14 at 05:04
  • Hi @mrjayviper, Have you got your answer ? Is my first console command help you or another one? – kuldipem Oct 02 '14 at 06:07
  • this is the error I'm getting with the first command: does not contain any mapped entities. – mrjayviper Oct 02 '14 at 06:34