Why is my Symfony2 install 404ing when I access app.php?(为什么我访问 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?
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Laravel 仓库 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
