沃梦达 / 编程问答 / php问题 / 正文

为什么我访问 app.php 时 Symfony2 安装 404ing?

Why is my Symfony2 install 404ing when I access app.php?(为什么我访问 app.php 时 Symfony2 安装 404ing?)

本文介绍了为什么我访问 app.php 时 Symfony2 安装 404ing?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Symfony2, when accessing my application locally via app_dev.php, everything works fine. However, when I access app.php it 404s:

哎呀!发生错误

服务器返回404 Not Found".

The server returned a "404 Not Found".

有些东西坏了.请在 [email] 给我们发电子邮件,让我们知道什么发生此错误时您正在做的事情.我们会尽快修复可能的.对不起

Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for

推荐答案

全新的 symfony 2 安装不包含任何用于生产环境的路由.如果您查看 app/config/routing_dev.yml 下的内容,您会注意到您在演示应用程序中看到的所有路由都是为开发而定义的.如果你想在 app.php 上测试 demo,你必须先将路由从 routing_dev.yml 复制到 routing.yml,然后还启用 AppKernel.php 下的 AcmeDemoBundle:

A fresh symfony 2 install does not contain any routing for the production environment. If you take a look under app/config/routing_dev.yml, you will notice that all of the routes that you see in the demo application are defined only for development. If you wish to test the demo on app.php, you have to first copy the routing from routing_dev.yml to routing.yml, and also enable the AcmeDemoBundle under you AppKernel.php:

$bundles = array(
        new SymfonyBundleFrameworkBundleFrameworkBundle(),
        new SymfonyBundleSecurityBundleSecurityBundle(),
        new SymfonyBundleTwigBundleTwigBundle(),
        new SymfonyBundleMonologBundleMonologBundle(),
        new SymfonyBundleSwiftmailerBundleSwiftmailerBundle(),
        new SymfonyBundleDoctrineBundleDoctrineBundle(),
        new SymfonyBundleAsseticBundleAsseticBundle(),
        new SensioBundleFrameworkExtraBundleSensioFrameworkExtraBundle(),
        new JMSSecurityExtraBundleJMSSecurityExtraBundle(),
+       new AcmeDemoBundleAcmeDemoBundle()
    }

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
-       $bundles[] = new AcmeDemoBundleAcmeDemoBundle();
        $bundles[] = new SymfonyBundleWebProfilerBundleWebProfilerBundle();
        $bundles[] = new SensioBundleDistributionBundleSensioDistributionBundle();
        $bundles[] = new SensioBundleGeneratorBundleSensioGeneratorBundle();
    } 

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

(+ is the line you should add, - is the line you should remove)

这篇关于为什么我访问 app.php 时 Symfony2 安装 404ing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:为什么我访问 app.php 时 Symfony2 安装 404ing?

基础教程推荐