symfony2错误自动创建getter和setter

时间:2014-06-12 19:00:30

标签: php symfony doctrine-orm doctrine

我从Symfony 2开始,我正在学习教程。 该教程是完美的,但有点细节。

我在TiendaBundle文件夹中有一个实体Tienda.php,其属性和映射良好。 是这样的:

// 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;
}

我的目的是通过任务自动生成getter和setter:

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

此任务会生成以下错误:

[RuntimeException的] 找不到“TiendaBundle”的基本路径(路径:“G:\ xampp \ htdocs \ cupon \ src \ cupon \ TiendaBundle”,目的地:G:\ xampp \ htdocs \ cupon \ src \ cupon \ TiendaBundle“)。
doctrine:generate:entities [--path =“...”] [ - no-backup] name

我需要为其他更大的项目自动生成getter和setter。 我希望你能帮忙!

3 个答案:

答案 0 :(得分:1)

通常,捆绑名称不仅仅是NameBundle,还有VendorNameBundle。 在你的情况下,它可能是CuponTiendaBundle。 你应该试着改为:

php app/console generate:doctrine:entities CuponTiendaBundle

如果它不起作用,您可以在app/AppKernel.php的内容中找到捆绑包的正确名称。您还可以在G:\xampp\htdocs\cupon\src\cupon\TiendaBundle\*SOMENAME*TiendaBundle.php中查看php文件的名称。

答案 1 :(得分:1)

如果参数错误可能是原因,请检查/app/config/parameters.yml中的数据库连接字符串。

答案 2 :(得分:-1)

Getter和setter世代更像是一个IDE功能(eclipse,phpstorm和许多其他人都做得很好)。

generate:doctrine:entities用于从头开始在数据库中创建实体