这是我最初的 MyEntity.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MyEntity
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="AppBundle\Entity\MyEntityRepository")
*/
class MyEntity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="string", type="string", length=255)
*/
private $string;
}
我很惊讶,因为当你运行命令时:
php app/console doctrine:generate:entities AppBundle/Entity/MyEntity
在我的实体中,生成了以下带有$condition的代码,而事实是我无法弄清楚它们是如何以及为什么被创建的。
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MyEntity
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="AppBundle\Entity\MyEntityRepository")
*/
class MyEntity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="string", type="string", length=255)
*/
private $string;
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set string
*
* @param string $string
* @return MyEntity
*/
public function setString($string) {
$this->string = $string;
return $this;
}
/**
* Get string
*
* @return string
*/
public function getString() {
return $this->string;
}
/**
* @var string
*/
private $condition;
/**
* Set condition
*
* @param string $condition
* @return MyEntity
*/
public function setCondition($condition)
{
$this->condition = $condition;
return $this;
}
/**
* Get condition
*
* @return string
*/
public function getCondition()
{
return $this->condition;
}
}
这是我的 composer.json
{
"name": "project/symfony2.8",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"symfony/assetic-bundle": "^2.8",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"sonata-project/doctrine-orm-admin-bundle": "~2.3",
"sonata-project/admin-bundle": "~2.3",
"sonata-project/user-bundle": "^2.2",
"sonata-project/intl-bundle": "^2.2",
"sonata-project/media-bundle": "^2.3",
"sonata-project/formatter-bundle": "^2.3",
"sonata-project/seo-bundle": "~1",
"jms/serializer-bundle": "~0.13",
"jms/i18n-routing-bundle": "^2.0",
"jms/translation-bundle": "^1.2",
"jms/di-extra-bundle": "^1.7",
"knplabs/doctrine-behaviors": "^1.3",
"a2lix/translation-form-bundle": "^2.1",
"oh/google-map-form-type-bundle": "dev-master",
"egeloen/google-map-bundle": "^2.2",
"willdurand/geocoder": "^3.3",
"widop/http-adapter-bundle": "^1.2",
"pixassociates/sortable-behavior-bundle": "^1.0",
"stof/doctrine-extensions-bundle": "^1.2",
"avegao/spain-validator-bundle": "^1.0",
"xmon/color-picker-type-bundle": "^1.0",
"urodoz/truncate-html": "@stable",
"suncat/mobile-detect-bundle": "0.10.*",
"symfony-cmf/seo-bundle": "^1.2",
"burgov/key-value-form-bundle": "^1.4"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.4.45"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "symlink",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}
有什么想法吗?多谢