You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Symfony4项目WebProfiler加载404错误求助

Hey there, let's fix that Web Profiler 404 error in your Symfony 4 project. I've run into this exact issue before, so here are the most common fixes to try:

1. Verify Web Profiler Routes Exist

First, check if the dev routing config for the profiler is in place. Navigate to config/routes/dev/web_profiler.yaml and make sure it contains this:

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

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

If this file is missing, reinstall the bundle with:

composer require --dev symfony/web-profiler-bundle
2. Ensure You're Running in Dev Environment

The Web Profiler only works in the dev environment. Check your .env file and confirm:

APP_ENV=dev

If you're using a server like Apache/Nginx, make sure the APP_ENV environment variable is set to dev (some servers override this in their configs).

3. Check Your Server Configuration
  • Built-in Server: If you're using Symfony's built-in server, run it from your project root with:
    symfony server:start
    
    Or the PHP built-in server:
    php -S localhost:8000 -t public
    
    Make sure you're pointing directly to the public directory as the document root.
  • Apache/Nginx: Ensure your web server's document root is set to the public folder, and that rewrite rules are working. For Apache, the default .htaccess in public should handle this—don't delete or modify it unless you know what you're doing. For Nginx, double-check your config includes rules to forward all requests to index.php.
4. Clear the Dev Cache

Cached routing data can sometimes cause issues. Clear the dev environment cache with:

php bin/console cache:clear --env=dev
5. Confirm the WebProfilerBundle is Enabled

Check config/bundles.php to make sure the bundle is enabled for the dev environment:

Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],

If this line is missing, add it and then re-run the cache clear command.

After trying these steps, refresh your page and click the "Open Web Profiler" link again—it should load correctly now!

内容的提问来源于stack exchange,提问作者Sander Bakker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:20:37