我已经在src/UserBundle/UserBundle.php中创建了新的bundle类
namespace AppBundle;
use Symfony'Component'HttpKernel'Bundle'Bundle;
class UserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
我试图在appkerner。php中加载
$bundles = array(
new Symfony'Bundle'FrameworkBundle'FrameworkBundle(),
new Symfony'Bundle'SecurityBundle'SecurityBundle(),
new Symfony'Bundle'TwigBundle'TwigBundle(),
new Symfony'Bundle'MonologBundle'MonologBundle(),
new Symfony'Bundle'SwiftmailerBundle'SwiftmailerBundle(),
new Symfony'Bundle'AsseticBundle'AsseticBundle(),
new Doctrine'Bundle'DoctrineBundle'DoctrineBundle(),
new Sensio'Bundle'FrameworkExtraBundle'SensioFrameworkExtraBundle(),
new AppBundle'AppBundle(),
new AppBundle'UserBundle(),
);
获取下一个错误-试图从命名空间"AppBundle"加载类"UserBundle"。您是否忘记了另一个名称空间的"use"语句?
应该如何加载?
bundle的问题与名称空间有关。正确的名称空间应该是:
namespace AppBundle'UserBundle;
use Symfony'Component'HttpKernel'Bundle'Bundle;
class UserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
然后加载为:
$bundles = array(
new AppBundle'UserBundle'UserBundle()
);
同样适用于您的AppBundle
包。顺便说一句,你可能应该把src/AppBundle
重命名为src/App
,以避免使用"bundle"这个词。