我设置了一个名为 Mine 的 Bundle:
src/Mine/DemoBundle/Controller
src/Mine/DemoBundle/Entity/user/User.php
我的路线是:
defaults: { _controller: MineDemo:User:create }
UserController.php 的开头是这样的:
namespace Mine\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Mine\DemoBundle\Entity\User;
class UserController extends Controller
{
public function createAction()
{
$user = new User();
$user->setName('Jonathan H. Wage');
$em = $this->get('doctrine.orm.entity_manager');
$em->persist($user);
$em->flush();
// ...
}
和 User.php 是:
namespace Mine\DemoBundle\Entity\User;
/**
* Mine\DemoBundle\Entity\User\User
*/
class User
{
/**
* @var integer $id
*/
private $id;
/**
* @var string $name
*/
private $name;
/**
* Get id
*
* @return integer $id
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get name
*
* @return string $name
*/
public function getName()
{
return $this->name;
}
}
我不断收到错误:
致命错误:在第 12 行的 C:\xampp\htdocs\Symfony\src\Mine\DemoBundle\Controller\UserController.php 中找不到类 'Mine\DemoBundle\Entity\User'