user3735385
user3735385

Reputation: 1

symfony2 error automatically create getters and setters

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!

Upvotes: 0

Views: 393

Answers (3)

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

Upvotes: 1

goto
goto

Reputation: 8162

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

Upvotes: -1

Einenlum
Einenlum

Reputation: 620

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.

Upvotes: 1

Related Questions