3

我是symfony的新手。

我做了:

rm -rf app/cache/*
rm -rf app/logs/*

然后:

sudo setfacl -R -m u:www-data:rwx -m u:user :rwx app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:user:rwx app/cache app/logs

ls -al给出:

drwxrwxrwx 3 user user  1024 мая   29 00:06 cache(cache is on green background)
drwxrwxrwx 2 user user  1024 мая   29 00:06 logs(logs is on green background)

现在我正在尝试访问 /Symfony/web/app_dev.php - 它显示:

加载 Web 调试工具栏时出错(404:未找到)。

是否要打开分析器?

当我单击确定时,它重定向到

/Symfony/web/app_dev.php/_profiler/bd8604738ac7af3c9d0611ea12076f0f62422601

并且找不到404文件..

这是 app/logs/dev.log

[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2013-05-29 00:12:29] request.INFO: Matched route "_welcome" (parameters: "_controller": "Acme\DemoBundle\Controller\WelcomeController::indexAction", "_route": "_welcome") [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\Fragment\FragmentHandler::onKernelRequest". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DeprecationLoggerListener::injectLogger". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\ChromePhpHandler::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\Fragment\FragmentHandler::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\Security\Http\RememberMe\ResponseListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\StreamedResponseListener::onKernelResponse". [] []
[2013-05-29 00:12:29] event.DEBUG: Notified event "kernel.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onKernelTerminate". [] []

没找到解决办法,求大神帮忙

编辑:

Routing_dev.xml

_welcome:
    pattern:  /
    defaults: { _controller: AcmeDemoBundle:Welcome:index }

_demo_secured:
    resource: "@AcmeDemoBundle/Controller/SecuredController.php"
    type:     annotation

_demo:
    resource: "@AcmeDemoBundle/Controller/DemoController.php"
    type:     annotation
    prefix:   /demo

_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.xml

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

#swiftmailer:
#    delivery_address: me@example.com

app_dev.php

<?php

use Symfony\Component\HttpFoundation\Request;

// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
4

5 回答 5

10

我的问题是kernel.terminate事件执行超过 10 秒。很难发现,因为分析器没有测量此事件的时间线。

当我意识到这一点时,我立即将问题缩小到我的一个事件侦听器具有异常长时间运行的__construct方法。此延迟配置文件打印时间过长,导致重试 5 次后出现 Javascript 超时错误。

修复有问题的侦听器后,kernel.terminate事件进展迅速,问题立即消失。

您可以使用bin/console debug:event-dispatcher kernel.terminate.

于 2015-12-02T16:50:39.733 回答
6

根据我自己的经验;当您更改路线的标准行为时,会发生此行为。例如,在我的例子中,我使用 kernel.request 监听器来创建一个语言检测机制,该机制应该根据她/他的浏览器支持的语言为用户选择最好的语言。

我在 app/config/routing.yml 中的所有路由中都使用了 {_locale} 前缀

some_route:
    resource: "@MyBundle/Resources/config/routing.yml"
    prefix:   /{_locale}/

通过这种方式,我能够在路由的开头快速添加语言代码,并且在我的侦听器类中,我将客户端重定向到以现有语言代码为前缀的路由,而不管客户端是否请求了带有或不带有语言环境的路由。

例如,如果我的网站只有“en”和“de”作为语言,并且用户请求

http://www.mysite.com/somepage

或者

http://www.mysite.com/fr/somepage

我正在将客户重定向到

http://www.mysite.com/en/somepage

因此,每当我的应用程序出现错误时,探查器路由并没有意识到这种情况,并试图从没有 {_locale} 前缀的路由中显示自己。这导致了 404 错误。

解决方案很简单:

我打开了 app/config/routing_dev.yml 文件并修改了所有路由,如下所示:

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

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

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

注意 /{_locale} 部分。

所以这个问题对我来说是固定的。

于 2013-08-04T20:37:04.243 回答
1

最终为我工作的是增加我的 php.ini 文件中的值,重新启动 php-fpm(例如,memory_limit),然后重新启动服务器()。如果在所有这些之后仍然无法正常工作,请尝试重新启动计算机。它为我的一个同事工作。max_execution_timebrew services restart php56sudo nginx -s reload

于 2017-02-22T17:00:13.993 回答
0

就我而言,这是一个路线冲突。我以与我的路线不冲突的方式更改了 routing_dev.yml 中的路线

于 2014-01-28T09:26:00.497 回答
0

也许您还没有包含 Web Profiler 的路线?

如果您发布您的config_dev.yml&routing_dev.yml也许我们可以看到有什么问题。

routing_dev.yml应该看起来像这样

_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 }
    - { resource: security_dev.yml }

framework:
    router:
        resource: "%kernel.root_dir%/config/routing_dev.yml"

还要确保app_dev.php将环境设置为dev喜欢

// ...
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
// ...
于 2013-05-28T20:20:45.937 回答