问题
I'm unable to use the symfony profiler after running composer req profiler
I'm using symfony/skeleton in version 4.0 beta, but i remember having the same problem when i tested it a few months ago in 3.3.
The toolbar isn't working, message here :
An error occurred while loading the web debug toolbar. Open the web profiler.
And when click on "open the web profiler", i have a 404 error.
If someone resolved it, thank you for your help. If not, I'll report a bug while this is still in bêta.
About installation : created a project with composer, with the symfony/skeleton package in version 4.0-beta linked here : https://github.com/symfony/skeleton
My php version is 7.1 ; i try to install profiler from the command above.
回答1:
Try following these steps:
composer create-project -s beta symfony/skeleton:4.0.x s40b1
cd s40b1
composer require web-server
composer require cli
composer require profiler
Add a controller
class DemoController extends AbstractController
{
public function demoAction()
{
$html = <<<EOT
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>s4b1</title></head>
<body>Demo Body</body>
</html>
EOT;
return new Response($html);
}
}
And a route
demo:
path: /demo
defaults: { _controller: 'App\Controller\DemoController::demoAction' }
Then
bin/console cache:clear
bin/console server:run
Navigate to
http://127.0.0.1:8000/demo
If it works then determine where your config is different.
回答2:
OP fixed his issue already, but I thought I'd comment on my experience. In my case, I used Flex to install the profiler just fine; checking out my app, routes were set correctly. I followed Symfony's guide to webserver configuration for Apache and PHP-FPM, which worked great for getting PHP files running. However, the section on rewrite rules for non-PHP files is in the mod_php section and not repeated in the FPM section. I missed this while reading through quickly. Specifically, you need to ensure you have the mod_rewrite block in your configuration as follows (use either the Apache 2.2 or 2.4 setting, not both):
DocumentRoot /var/www/project/public
<Directory /var/www/project/public>
AllowOverride None
# Apache 2.2
Order Allow,Deny
Allow from All
# /Apache 2.2
# Apache 2.4
Require all granted
# /Apache 2.4
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
回答3:
I just had the same issue.
I installed it using composer require profiler --dev
then I installed twig cause I wanted to return a view instead of Response object, but the profiler didn't work.
the reason was that I've created a Twig template that isn't extending base.html.twig that is just a simple html layout that has the html,body,head, and title tags.
so it turns out that the profiler needs the body tag within the markup Response you are returning.
so, all i did was adding {% extends 'base.html.twig' %}
in the top of my new template.
and it worked!
来源:https://stackoverflow.com/questions/46918623/cant-install-profiler-symfony-flex