0
votes

I´m starting with Symfony 2 and I´m following a tutorial. The tutorial is perfect but a little detail.

I have a Entity Tienda.php inside the folder TiendaBundle with properties and well mapped. Is this:

// src/Cupon/TiendaBundle/Entity/Tienda.php

namespace Cupon\TiendaBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity */
class Tienda
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
protected $id;

/** @ORM\Column(type="string", length=100) */
protected $nombre;

/** @ORM\Column(type="string", length=100) */
protected $slug;

/** @ORM\Column(type="string", length=10) */
protected $login;

/** @ORM\Column(type="string", length=255) */
protected $password;

/** @ORM\Column(type="string", length=255) */
protected $salt;

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

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

/** @ORM\ManyToOne(targetEntity="Cupon\CiudadBundle\Entity\Ciudad") */
protected $ciudad;
}

My intention is generate the getters and setters automatically with task:

G:\xampp\htdocs\cupon>php app/console generate:doctrine:entities TiendaBundle

This task generates the following error:

[RuntimeException] Can´t find base path for "TiendaBundle" (path: "G:\xampp\htdocs\cupon\src\cupon\TiendaBundle", destination: G:\xampp\htdocs\cupon\src\cupon\TiendaBundle").
doctrine:generate:entities [--path="..."] [--no-backup] name

I need generate getters and setters automatically for others projects more larger. I hope your help plis!

3
How did you create that mapping? You may try php app/console doctrine:generate:entity which ask for the BundleName and(:) entity name; then you will ask for field names - Javad
I dont have DataBase. I try this task php app/console generate:doctrine:entities TiendaBundle:Tienda but retorned same error. Help plis! - user3735385
OK; if you go to src/Cupon/TiendaBundle folder, you will find there is php file named ...Bundle.php; Open it and let us know what's the name of that Class. Second) make sure that className is added in the bundles array in AppKernel.php - Javad
Yes in my appKernel.php there is new cupon\TiendaBundle\TiendaBundle(), and in my class TiendaBundle.php there is class TiendaBundle extends Bundle { } and the other things for example namespace etc... - user3735385
This is solved. I have reinstalled the framework but i think the problem was namespace with uppercase and lowercase. Is case sensitive. ;) - user3735385

3 Answers

1
votes

Generally the bundle name is not just NameBundle but VendorNameBundle. In your case it is probably CuponTiendaBundle. You should try instead:

php app/console generate:doctrine:entities CuponTiendaBundle

If it does not work, you can find the right name of your bundle in the content of app/AppKernel.php. You can also look at the name of the php file in G:\xampp\htdocs\cupon\src\cupon\TiendaBundle\*SOMENAME*TiendaBundle.php.

1
votes

Check your database conection string in /app/config/parameters.yml if the parameters are wrong may be the cause.

-1
votes

Getter and setters generations are more an IDE features (eclipse, phpstorm and many others do it fine).

generate:doctrine:entities is used to create an entity into the database from scratch