当我访问app.php时,为什么我的Symfony2会安装404?

siw*_*lek 39 php frameworks symfony

在Symfony2中,当通过app_dev.php在本地访问我的应用程序时,一切正常.但是,当我访问app.php时它是404s:

哎呀!发生错误

服务器返回"404 Not Found".

有些东西坏了.请发送电子邮件至[email],告诉我们发生此错误时您在做什么.我们会尽快修复它.对于某事很抱歉

Nem*_*vić 22

新的symfony 2安装不包含生产环境的任何路由.如果你仔细看看app/config/routing_dev.yml,你会发现你在演示应用程序中看到的所有路径都只是为了开发而定义的.如果您希望测试演示app.php,则必须先将路由复制routing_dev.ymlrouting.yml,然后启用AcmeDemoBundle以下内容AppKernel.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\DoctrineBundle\DoctrineBundle(),
        new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
+       new Acme\DemoBundle\AcmeDemoBundle()
    }

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
-       $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
        $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
        $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
    } 
Run Code Online (Sandbox Code Playgroud)

(+是你应该添加的行, - 是你应该删除的行)


you*_*man 16

我有同样的问题,我只是清除了缓存.php app/console cache:clear --env=prod这解决了我的问题.

不要将该属性设置为true:$ kernel = new AppKernel ('prod', TRUE);它将激活调试模式,不建议用于prod.