从 symfony 2 开始(app_dev.php 有效,app.php 404) [英] starting with symfony 2 (app_dev.php works, app.php 404's)

查看:23
本文介绍了从 symfony 2 开始(app_dev.php 有效,app.php 404)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 symfony 的教程,但遇到了障碍.

I was following the tutorials for symfony, and have hit a road block.

我的设置是 xampp 的当前版本(在 Windows 上运行),所以我的 apache 和 php 相对最新.

my setup is the current version of xampp (running on windows), so my apache and php are relatively up to date.

在此处关注他们的快速浏览":

following their "quick tour" here:

http://symfony.com/doc/current/quick_tour/the_big_picture.html

在开发环境中一切正常.然而,进一步遵循指南,我开始通过此处的指南创建自己的测试包:

everything worked great in the development environment. following the guides a little further however, i started creating my own test bundle via the guide here:

http://symfony.com/doc/current/book/page_creation.html

并且无法让它在生产环境中正常工作.(它在开发环境中运行良好,就像预装的演示一样.

and can't get it to work properly on the production environment. (it works fine in the dev environment, just like the pre-installed demos did.

我尝试通过 php app/console cache:clear --env=prod --no-debug 命令清除缓存,但这并没有帮助(而且似乎也是搜索时弹出的唯一建议.

i have tried clearing the cache via the php app/console cache:clear --env=prod --no-debug command, however that did not help (and also seems to be the only suggestion that pops up upon searching.

查看路线时,我可以看到我的/hello/{name}"路线在路线列表中显示良好.

when viewing the routes, i can see that my "/hello/{name}" route is showing up fine on the list of routes.

我的 app/config/routing.yml 有:

my app/config/routing.yml has:

acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    prefix:   /

它应该,然后我的 src/Acme/HelloBundle/Resources/config/routing.yml 有

as it should, and then my src/Acme/HelloBundle/Resources/config/routing.yml has

hello:
    path:     /hello/{name}
    defaults: { _controller: AcmeHelloBundle:Hello:index }

有没有人对可能出现的问题有任何建议?(我还尝试通过从routing_dev.yml 文件中复制路由信息并重新分配appkernel.php 文件中的包,将开箱即用的演示转换为生产路由,但存在同样的问题)

does anyone have any suggestions as to what the problem might be? (i have also tried converting the out of the box demo to a production route, by copying the route info from the routing_dev.yml file and reassigning the bundle in the appkernel.php file, but that had the same problem)

---编辑---

每个请求,这是我的 appkernel.php 文件

per request, here is my appkernel.php file

使用Symfony\Component\HttpKernel\Kernel;使用 Symfony\Component\Config\Loader\LoaderInterface;

use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface;

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 JMS\AopBundle\JMSAopBundle(),
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
            new Acme\HelloBundle\AcmeHelloBundle(),
            new Acme\DemoBundle\AcmeDemoBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}

---第二次编辑---

---2nd edit---

我发现了问题.我觉得 prod 日志中没有显示任何内容很奇怪,所以我想可能是有什么东西在重定向我,导致我完全错过了 app.php 文件.

i found the problem. i thought it was strange that nothing was showing up in the prod log, so i thought maybe something was redirecting me, causing me to miss the app.php file entirely.

事实证明,这就是问题所在.我清空了 web 文件夹中的 .htaccess 文件的内容(symfony 预配置的那个),然后一切都神奇地开始工作了.

it turns out, this was the problem. i emptied the contents of the .htaccess file that was in the web folder (the one that symfony came preconfigured with) and then everything magically started working.

推荐答案

我发现了问题.我觉得 prod 日志中没有显示任何内容很奇怪,所以我想可能是有什么东西在重定向我,导致我完全错过了 app.php 文件.

i found the problem. i thought it was strange that nothing was showing up in the prod log, so i thought maybe something was redirecting me, causing me to miss the app.php file entirely.

事实证明,这就是问题所在.我清空了 web 文件夹中的 .htaccess 文件的内容(symfony 预配置的那个),然后一切都神奇地开始工作了.

it turns out, this was the problem. i emptied the contents of the .htaccess file that was in the web folder (the one that symfony came preconfigured with) and then everything magically started working.

这篇关于从 symfony 2 开始(app_dev.php 有效,app.php 404)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆