Symfony Controller不存在或未启用

时间:2015-05-20 14:49:28

标签: php symfony

我刚刚开始使用Symfony,我正在努力加载默认的controller.php。我检查了所有文件,不知道我哪里出错了。我的错误是;

  

CRITICAL - 未捕获的PHP异常InvalidArgumentException:“The   “DefaultController”(来自_controller值   “DefaultController:Default:index”)不存在或未启用   你的内核!“在   C:\ Users \用户PC \文件\ XAMPP \ htdocs中\代码\ testProject \厂商\ symfony的\ symfony的\ SRC \的Symfony \捆绑\ FrameworkBundle \控制器\ ControllerNameParser.php   第72行上下文:{“exception”:“Object(InvalidArgumentException)”}

我的控制器在那里;

enter image description here

AppKernel.php引用目录

class AppKernel extends Kernel
{
public function registerBundles()
{
    $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(), << HERE

据我所知,routing.dev和路由文件也是正确的

routing_dev.yml

_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix:   /_wdt

_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix:   /_profiler

_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix:   /_configurator

_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix:   /_error

_welcome:
pattern:  /
defaults: { _controller: DefaultController:Default:index }

_main:
resource: routing.yml

的routing.yml

j_m_khello:
resource: "@jMKhelloBundle/Resources/config/routing.php"
prefix:   /

app:
resource: "@AppBundle/Controller"
type:     annotation

任何帮助非常感谢

1 个答案:

答案 0 :(得分:2)

这不是有效的控制器参考。正确的格式为BundleName:ControllerName:action_name,因此适合您的应用

AppBundle:Default:index