问题描述
在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)