[英]Symfony 4 : An error occurred while loading the web debug toolbar
我在 CentOS 上工作。
我已經按照教程:
當我使用 Apache 時,我也關注了這個頁面:
我做了一個默認控制器和一個默認模板。 使用此控制器 (/),我收到以下錯誤(在調試工具欄中):
An error occurred while loading the web debug toolbar. Open the web profiler.
當我點擊鏈接:“打開網絡分析器”時,我可以看到 Apache 響應:
Not Found
The requested URL /_profiler/177403 was not found on this server.
在 chrome 檢查器中,我可以看到:GET http://172.31.18.7/_wdt/177403 404(未找到)
這是我的 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 :
<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 :
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 消息:
Not Found
The requested URL /lucky/number was not found on this server.
看起來路由組件不起作用。
路由器規則(調試:路由器):
-------------------------- -------- -------- ------ -------------------
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,以防萬一,但它沒有改變任何東西。
我已經用 debug:event-dispatcher 檢查過錯誤,沒什么特別的。
我注意到分析器的緩存位於該目錄中:var/cache/dev/profiler/03/74/ 並命名為 177403
還有一件事,我用“root”用戶運行作曲家。 我已經使用 chown 更改了我的項目的所有者。
這是我的文件 .env 的一部分:
###> symfony/framework-bundle ###
APP_ENV=dev
我認為這是需要 htaccess 或 mod_rewrite
composer require symfony/apache-pack
只需添加:
回退資源/index.php
在您的目錄設置中
<Directory "/Library/WebServer/Documents/Your_public_symfony_directory"> .... FallbackResource /index.php .... </Directory>
有關更多文檔, 請單擊此處
composer require symfony/apache-pack
Do you want to execute this recipe?
[y] Yes
[n] No
[a] Yes for all packages, only for the current installation session
[p] Yes permanently, never ask again for this project
(defaults to n): y
主機文件:
127.0.0.1 symfony01.com
127.0.0.1 www.symfony01.com
httpd-vhosts.conf :
<VirtualHost *:80>
ServerName symfony01.com
ServerAlias www.symfony01.com
DocumentRoot "c:/wamp64/www/symfony01/public"
<Directory "c:/wamp64/www/symfony01/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
由於回復在評論中,我重復一遍:
您是否嘗試過 URL http://www.elora.dev/index.php/_wdt/ ? 我有一個類似的問題,因為 URL 重寫是錯誤的。 – AL
就是這樣 !
非常感謝AL
Il 聽起來像是緩存寫入問題。 探查器/調試工具欄崩潰,因為調試數據被寫入緩存文件夾。 您的應用程序可能在prod
環境中運行良好。
要查看這是否是您的問題,請嘗試運行chmod -R 777 var/cache
,然后重試。
“更好的修復”取決於您的操作系統。 隨意添加更多信息以准確回答,否則您可以在此處查看 Symfony 相關文檔(故意過時的鏈接,他們將其從 SF4 文檔中刪除)。
如果您使用的是 symfony v5。 *
轉到your_project_root > public
創建一個名為.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>
如果您需要更多信息,您可以訪問這里
我有同樣的錯誤,這些解決方案沒有幫助。 就我而言,這是一個更簡單的問題。 我將 symfony 從 4.2 升級到 4.3,但沒有將其他軟件包(包括 Web Profiler)升級。 哎呀! 在 composer.json 中檢查 Web Profiler 的版本。
有時,您的控制器中可以有一條路由來捕獲/_wdt/125121
,如下所示:
@Route("/{_locale}/{courseSlug}", name="learning_course")
Web debug
工具欄的請求將被routed
到這里而不是正確的控制器。
使用route requirements
或修復您的路線。
我有錯誤:
無法訪問字符串變量的屬性(“nb_errors”)
從 4.2 升級到 Symfony 到 4.3 解決了我的問題
如果這通常發生在某人身上,而工具欄之前確實有效,則作為對先前答案的一個小補充:
這也可能是由於不幸的重命名造成的,人們可能通過替換所有.
在這種情況下,甚至可能只發出以下命令就足夠了:
bin/console cache:clear
突然收到錯誤信息的其他可能原因
“加載 Web 調試工具欄時出錯。”
我做了什么以及在我的情況下解決了什么:
重新啟動 vagrant(當然,如果您在 vagrant 中運行它)
刪除所有日志文件(尤其是你的 dev.log)
rm -rf var/logs
清除緩存
bin/console cache:clear # OR if cache got corrupted rm -rf var/cache
這是 Web 調試工具欄通常顯示但突然停止顯示的時間
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.