Symfony的2 - 在加载网页调试工具出现错误(404:未找到)(Symfony 2 - An

2019-09-01 05:30发布

由于更新到symfony的2.2,网页调试工具栏不再app_dev.php加载。

我得到以下错误:

An error occurred while loading the web debug toolbar (404: Not Found).
Do you want to open the profiler?

在prod.log我得到如下:

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /_profiler/84fb75cc3ffd5435474ebe4250e01fac2cdf49c1"" at /httpdocs/project/app/cache/prod/classes.php line 3597 [] []

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /_wdt/452d5b4aa2dd9388285fa1c286d5c54218029c71"" at /httpdocs/priject/app/cache/prod/classes.php line 3597 [] []

我已经清除缓存几次:)

有趣的是,在/app_dev.php页面不再链接上的所有链接到/app_dev.php。

包括轮廓(/ _profiler / 5fdc27cb82c4e9e426b3ab27377deb0b760fdca2)当我手动修改的URL,和app_dev.php正确地添加到URL,分析器负载。

routing_dev.yml:

_assetic:
    resource: .
    type:     assetic

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_configurator:
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
    prefix:   /_configurator

_main:
    resource: routing.yml

我会感谢任何帮助。

更新我:config_dev.yml

imports:
    - { resource: config.yml }

framework:
    router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: false

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type:  firephp
            level: info
        chromephp:
            type:  chromephp
            level: info

assetic:
    use_controller: true

更新二:AppKernel.php

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 myProject\MyBundle\myBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new myProject\MyBackendBundle\myBackendBundle(),
       );

        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');
    }
}

更新三:的.htaccess

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

更新:我已经发现了错误,这是一个错误的(旧)在模板渲染标签。 :(

感谢您的支持

Answer 1:

我有这个问题太,尽量要注意你的.htaccess,使它看起来像这样:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the startpage to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>


Answer 2:

在Symfony的4 + Flex的我只好装symfony/apache-pack recipie

composer req apache-pack


Answer 3:

我在一个新的Linux系统中安装我的应用程序后,有这方面的问题。 我刚刚忘了在Apache2的激活的mod_rewrite

[sudo] a2enmod rewrite
[sudo] service apache2 restart

希望这将有助于!



Answer 4:

这个错误的另一个来源:更新Apache Web服务器,而不取消对重写模块。 通过实践学习!



Answer 5:

我碰到这个错误来了,当我修改供应商代码进行调试。 (我不知道这是不正确的做法,但无论如何..我做了修改,测试的Web应用程序,忘了回滚供应商代码)。

如果是你的情况,你不记得确切位置你做的“非法”更改供应商代码,您可以删除供应商目录或它的组件和运行php composer.phar update命令拉原始版本。



Answer 6:

您的重写规则可能是导致它。 就在几分钟前,我重写我的,我曾与探查同样的问题。



Answer 7:

对我来说,这种情况发生的时候我为了调用,而不是app.php app_dev.php改变的.htaccess(从网页目录),但我并没有在.htaccess文件中无处不在改变它。 改变后,这一切都出场app_dev.php错误消失。



Answer 8:

只是做重新启动你的WAMP / LAMP,它为我工作。



文章来源: Symfony 2 - An error occurred while loading the web debug toolbar (404: Not Found)