I am working on a Symfony2 project, I am trying to enable the profiler so i can do further debugging. I expect to see X-debug-token-link under Response Headers but i dont see it and i cant see the toolbar at the bottom of my page.
In my routing_dev.yml it seems that these options are enabled:
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: true }
web_profiler:
toolbar: true
intercept_redirects: false
Yet I cannot reach the profiler. Is there anything I am missing...?
Make sure you run your application in dev or test environment. Even though the cookbook states that collect is enabled by default, I had to set it explicitly to activate the profiler. At least in version 2.7. Here's the configuration I use:
# app/config/dev/config.yml
framework:
# activate profiler in framework
profiler:
collect: true
# configure profiler
web_profiler:
# display the web debug toolbar at the bottom of pages with a summary of profiler info
toolbar: true
# gives you the opportunity to look at the collected data before following the redirect
intercept_redirects: false
# Exclude AJAX requests in the web debug toolbar for specified paths
excluded_ajax_paths: ^/bundles|^/_wdt
Further reading:
FrameworkBundle Configuration ("framework") profiler
WebProfilerBundle Configuration ("web_profiler")
Make sure your app_dev.php or other entry point enables the debugging:
Debug::enable();
Also make sure your routing_dev.yml contains the profiler routes:
_profiler:
resource: "#WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
Related
Symfony version: 5.4.8
Project works fine but debug toolbar is all time retrying to load...
But if I start project with symfony serve and access localhost:8000 toolbar works, maybe is because toolbar is trying to access to "localhost" instead of "mydomain.test"? Anyone knows how to fix it?
Tried to install/reinstall profiler, debug, debug-bundle, apache-pack
//web_profiler.yaml
when#dev:
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }
when#test:
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }
//.env
APP_ENV=dev
APP_DEBUG=true
APP_SECRET=82fbd2b7ed4fb66bad6ce0fa48861ed5
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
DATABASE_URL="mysql://root:secret#localhost:3306/frikili?serverVersion=5.7&charset=utf8mb4"
I made a Symfony 4 application with webpack dev server for dev environment.
When I use the bin/console cache:clear command or go on the app via a browser, I get an error which tells me that I request an non existant service called "C".
I think the error is linked to the routing of the assets.
The error is launch when my dev server isn't running and sometimes even if it is.
But if I remove the strict_requirements: true in routing.yaml the error won't appear.
webpack.config.js
devServer: {
public: 'dev.myapp.io:8080',
contentBase: path.resolve(__dirname, 'public'),
headers: {
'Access-Control-Allow-Origin': '*'
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
ignored: /node_modules/
},
historyApiFallback: true,
compress: true,
noInfo: true,
quiet: true,
port: devServerPort,
}
config/packages/dev/framework.yaml
framework:
router: { resource: '%kernel.project_dir%/config/packages/dev/routing.yaml' }
profiler: { only_exceptions: false }
assets:
base_urls: 'http://localhost:8080'
json_manifest_path: '%kernel.project_dir%/public/dist/manifest.json'
config/packages/dev/routing.yaml
framework:
router:
strict_requirements: true
The error
In Container.php line 277:
You have requested a non-existent service "C". Did you mean one of these:
"MyApp\Controller\Home\HomeController",
"Symfony\Bundle\FrameworkBundle\Controller\RedirectController",
"Symfony\Bundle\FrameworkBundle\Controller\TemplateController"?
If someone knows how to avoid the error, I'll be grateful :)
I'd like to keep the strict_requirements to true but I don't have other solutions for now.
This error surfaces when when the config's are duplicated across files. So for instance, if in your config/packages/framework.yaml you have
# config/packages/framework.yaml
framework:
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
and then you have in
# config/packages/routing.yaml
framework:
router:
# strict_requirements: ~
utf8: true
you might get the error you posted. You cannot duplicate config over multiple files. Either remove the routing.yaml file or remove router key from config/packages/framework.yaml
Hope it helps.
I have a Symfony instance running on Linux with apache y NGINX. I'am starting the project using the built-in server:start command:
php bin/console server:start
Back to my browser, it loads me the Symfony start page but it also shows me the debug bar.
I have checked the config_dev.yml file and I think it is correct:
imports:
- { resource: config.yml }
framework:
router:
resource: '%kernel.project_dir%/app/config/routing_dev.yml'
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
However, if I try to access another route that I don't have, the debug bar is also shown:
You can access the prod env with:
http://127.0.0.1:8000/app.php
And accessing http://127.0.0.1:8000/app.php/a will give you an error page without the debug bar.
It is designed like this because the Symfony built-in web server is only meant to be used in development not in production. So the default environment is the "dev" one.
I just follow this tutorial. I created a new controller but my web debug toolbar doesn't show up. I accessed it via app_dev.php file, like , myurl/web/app_dev/contact/ even if i access my url without the contact the web debug toolbar doesn't show up.
This is my config_dev.yml file:
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
#swiftmailer:
# delivery_address: me#example.com
Do i need to do some extra settings ? I'm totally lost. Thx in advance.
Double check that you are actually accessing app_dev.php. For example try renaming app_dev.php to a new name 'app_dev_temp.php', then try reloading the page. If you can still access the page you are not where you think you are.
Also check your .htaccess file, if you are using a real server instead of the Symfony built in server, by default the htaccess will direct you to the app.php, not the dev version.
I have a weird issue, when I checked my app/log/dev.log I can see almost all of my queries in my dev.log being logged in real time:
[2015-01-27 06:57:22] doctrine.DEBUG: SELECT t0.username A ....
[2015-01-27 06:57:23] doctrine.DEBUG: SELECT t0.username A ...
[2015-01-27 06:57:23] doctrine.DEBUG: SELECT s0_.id ......
I have no idea why this is happening, since I am running the site on production mode also when I check monolog in my config.yml, this is what I see:
monolog:
handlers:
pictures:
type: stream
path: %kernel.logs_dir%/pictures_%kernel.environment%.log
level: info
instagram:
type: stream
path: %kernel.logs_dir%/instagram_%kernel.environment%.log
level: info
here's what my config_dev.yml looks like:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: false
hip_mandrill:
disable_delivery: true
any idea how this could be happening?
You should use prod env on your production server. In the prod env doctrine's logging is disabled by default.
But if you want to disable logging at all (in all environments) you need to set up a config.yml like that:
doctrine:
dbal:
connections:
conn1:
driver: ...
...
logging: false
profiling: false
Reference: https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html
I encountered a similar issue with dev.log being generated on prod environment. I figured out from the log entries that what was causing my issue was a scheduled cron job calling a custom symfony command. Modifying the entry to app/console with --env=prod for my crontab since stopped dev.log being generated. i.e.
app/console --env=prod custom:command
Must have missed that section of the book :)
As I struggled with the same problem and my .log file was increasing its size the straight solution was when running the consumer use the flag --no-debug
php bin/console messenger:consume async_email_handler --no-debug