Symfony 4:加载 Web 调试工具栏时出错 [英] Symfony 4 : An error occurred while loading the web debug toolbar

查看:18
本文介绍了Symfony 4:加载 Web 调试工具栏时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CentOS 上工作.

I work on CentOS.

我已按照教程进行操作:

I've followed the tutorials :

https://symfony.com/doc/current/page_creation.html

当我使用 Apache 时,我也关注了这个页面:

As I use Apache, I've followed this page too :

我制作了一个默认控制器和一个默认模板.使用此控制器 (/),我收到以下错误(在调试工具栏中):

I made a default controller and a default template. With this controller (/) I get the the following error (within the debug toolbar):

An error occurred while loading the web debug toolbar. Open the web profiler.

当我点击链接:打开网络分析器"时,我可以看到 Apache 响应:

When I click on the link : "Open the web profiler", I can see the Apache response :

Not Found
The requested URL /_profiler/177403 was not found on this server.

在 chrome 检查器中,我可以看到:GET http://172.31.18.7/_wdt/177403 404(未找到)

In the chrome inspector, I can see : GET http://172.31.18.7/_wdt/177403 404 (Not Found)

这是我的 composer.json 中有趣的部分:

Here's the interesting part of my composer.json :

    "require": {
        "php": "^7.1.3",
        "ext-iconv": "*",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "sensio/framework-extra-bundle": "^5.1",
        "sonata-project/admin-bundle": "^3.35",
        "sonata-project/doctrine-orm-admin-bundle": "^3.6",
        "symfony/apache-pack": "^1.0",
        "symfony/console": "^4.0",
        "symfony/flex": "^1.0",
        "symfony/framework-bundle": "^4.0",
        "symfony/lts": "^4@dev",
        "symfony/maker-bundle": "^1.4",
        "symfony/orm-pack": "^1.0",
        "symfony/requirements-checker": "^1.1",
        "symfony/security-bundle": "^4.0",
        "symfony/twig-bundle": "^4.0",
        "symfony/validator": "^4.0",
        "symfony/yaml": "^4.0"
    },
    "require-dev": {
        "sensiolabs/security-checker": "^4.1",
        "symfony/dotenv": "^4.0",
        "symfony/web-profiler-bundle": "^4.0"
    },

我的 httpd.conf :

my httpd.conf :

<VirtualHost *:80>
DocumentRoot /var/www/html/elora/public
ServerName eloradev
ServerAlias www.elora.dev
DirectoryIndex index.php

<Directory "elora/public">
    AllowOverride all
    Order Allow,Deny
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    Allow from localhost
</Directory>

<Directory elora>
    Options FollowSymlinks
</Directory>    

ErrorLog /var/apache/logs/error.log
CustomLog /var/apache/logs/access.log combined  

</VirtualHost>

还有我的 .htaccess :

And my .htaccess :

DirectoryIndex index.php

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 307 ^/$ /index.php/
    </IfModule>
</IfModule>

最后,我的/lucky/number (https://symfony.com/doc/current/page_creation.html) 引发 apache 消息:

And, to finish, my /lucky/number (https://symfony.com/doc/current/page_creation.html) raises the apache message :

Not Found
The requested URL /lucky/number was not found on this server.

看起来路由组件不起作用.

It looks like the routing component does'nt work.

路由器规则(debug:router):

The router rules (debug:router) :

-------------------------- -------- -------- ------ -------------------
Name                       Method   Scheme   Host   Path
-------------------------- -------- -------- ------ ----------------------- 
  app_homepage               ANY      ANY      ANY    /
  app_lucky                  ANY      ANY      ANY    /lucky
  app_lucky_number           ANY      ANY      ANY    /lucky/number
  _twig_error_test           ANY      ANY      ANY    /_error/{code}.{_format}
  _wdt                       ANY      ANY      ANY    /_wdt/{token}
  _profiler_home             ANY      ANY      ANY    /_profiler/
  _profiler_search           ANY      ANY      ANY    /_profiler/search
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results
  _profiler_open_file        ANY      ANY      ANY    /_profiler/open
  _profiler                  ANY      ANY      ANY    /_profiler/{token}
  _profiler_router           ANY      ANY      ANY    /_profiler/{token}/router
  _profiler_exception        ANY      ANY      ANY    /_profiler/{token}/exception
  _profiler_exception_css    ANY      ANY      ANY    /_profiler/{token}/exception.css
 -------------------------- -------- -------- ------ -----------------------

我手动创建了目录/_wdt,以防万一,但它没有改变任何东西.

I've manually created the directory /_wdt, in case, but it did'nt change anything.

我已经用 debug:event-dispatcher 检查过错误,没什么特别的.

I've checked errors with debug:event-dispatcher, nothing special.

我注意到分析器的缓存位于该目录中:var/cache/dev/profiler/03/74/并命名为 177403

I've noticed that the cache for the profiler is in that directory : var/cache/dev/profiler/03/74/ and is named 177403

还有一件事,我用root"用户运行了composer.我已经使用 chown 更改了我的项目的所有者.

One more thing, I've ran composer with the 'root' user. And I've used chown to change the owner of my project.

这是我的文件 .env 的一部分:

Here's a part of my file .env :

###> symfony/framework-bundle ###
APP_ENV=dev

推荐答案

我认为这需要 htaccess 或 mod_rewrite

I think this is require htaccess or mod_rewrite

composer require symfony/apache-pack

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