【问题标题】:Symfony 2.4: An error occurred while loading the web debug toolbar (404: Not Found)Symfony 2.4:加载 Web 调试工具栏时出错(404:未找到)
【发布时间】:2014-01-30 06:40:33
【问题描述】:

我刚刚在 Debian 7.3 上下载了 Symfony 2.4.1 的新副本。

URL /Symfony/web/config.php 正确打开,但是当我继续配置时,我得到:

The requested URL /Symfony/web/app_dev.php/_configurator/ was not found on this server.

如果我绕过配置并打开 /Symfony/web/app_dev.php 页面显示,但弹出错误提示:

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

如果我接受,我会得到:

The requested URL /Symfony/web/app_dev.php/_profiler/54a8bf was not found on this server.

在其他问题(例如Symfony 2: 404 Not Found Error when tryes to open /app_dev.php)中,人们建议摆弄 .htaccess 文件。 我什至尝试删除它,但它没有效果。

apache日志文件显示:

File does not exist: /var/www/Symfony/web/app_dev.php/_wdt/54a8bf, referer: http://wwwtest.di.unipi.it/Symfony/web/app_dev.php
File does not exist: /var/www/Symfony/web/app_dev.php/_profiler/54a8bf

所以看起来路由到任何内部 URL 都失败了,尽管正确的路由似乎已经到位:

> app/console router:debug
[router] Current routes
 Name                      Method Scheme Host Path
 _wdt                      ANY    ANY    ANY  /_wdt/{token}
 _profiler_home            ANY    ANY    ANY  /_profiler/
 _configurator_home        ANY    ANY    ANY  /_configurator/
...

【问题讨论】:

  • 找到了解决方案。必须将 AcceptPathInfo On 添加到 apache vhost 配置或 .htaccess 中。
  • 请修正标题中的错字。 ;)
  • 如果您找到了解决方案,您是否可以回答您自己的问题,以便其他人在寻找时更容易从答案中受益。
  • 已解决,请在此处查看我的答案:stackoverflow.com/a/30313196/1700429
  • 任何使用 nginx 的人,这对我有用:在 /etc/nginx/conf.d/default.conf 中替换 try_files $uri $uri/ /index.php?$args;通过 try_files $uri $uri/ /project-name/web/app_dev.php?$args;我自己在 ~/Projects/project-name 中有我的 symfony 项目,在 /usr/share/nginx/html/project-name 中有一个指向我的物理项目的符号链接。

标签: symfony configuration routing


【解决方案1】:

我已将/etc/php5/fpm/php.ini 中的memory_limit 更改为512Mb,调试工具栏开始工作。

Found solution for me here

【讨论】:

    【解决方案2】:

    我的解决方案是将我的 app_dev.php 文件更新为类似于 Symfony2 存储库中的文件

    注意正在使用的 Debug 类。这在旧版本的 symfony 中没有使用。我更新了这个文件,javascript 警报似乎消失了。

    <?php
    
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\Debug\Debug;
    
    // 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';
    Debug::enable();
    
    require_once __DIR__.'/../app/AppKernel.php';
    
    $kernel = new AppKernel('dev', true);
    $kernel->loadClassCache();
    $request = Request::createFromGlobals();
    $response = $kernel->handle($request);
    $response->send();
    $kernel->terminate($request, $response);
    

    【讨论】:

      【解决方案3】:

      以下内容是否存在于 web/app_dev.php 中?下面的行为我修复了它。

      $kernel->terminate($request, $response);
      

      【讨论】:

        【解决方案4】:

        Apache 指令DirectoryIndex app.php 为我解决了问题。 我将它放在带有AllowOverride None 的apache vhost conf 中,以防止被.htacces 覆盖。

        希望对您有所帮助。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-09-30
          • 1970-01-01
          • 2015-02-24
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多