Reputation: 239
When I visit http://localhost/web/app_dev.php
I get a very nice web debug toolbar but It doesn't appear in the views rendered by "custom" controllers.
What to do so the debug toolbar to be visible in the views rendered by controllers ?
Here is an example of the controller I use
namespace SD\BlogBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ContactsController extends Controller
{
public function indexAction()
{
$data = 'Lorem ipsum';
return $this->render('SDBlogBundle:Default:index.html.twig', array('data' => $data));
}
}
Upvotes: 12
Views: 16131
Reputation: 1
for me the problem was that I had de meta tag pointing to my prod environment.
then in the template ::base.html.twig in dev
<!--<base href="http://www.exemple.com" />-->
in prod:
<base href="http://www.exemple.com" />
Upvotes: 0
Reputation: 522
The toolbar inserts itself in pages by looking for a terminating </body> tag on your generated page.
If you don't have a </body> tag in your page the toolbar will not appear.
You also need to make sure you're using the dev mode by accessing the page via app_dev.php, e.g.
http://example.com/app_dev.php/hello/world
Upvotes: 51
Reputation: 9246
If it doesn't appear in "custom" controllers as you said, but appears in others, you probably have invalid html code.
Symfony2 only shows toolbar if your controller renders HTML. If it's invalid, it can't know it's HTML.
Reason: If your controller returns some other type (such as XML or JSON), Adding toolbar there would not just be useless but also break stuff.
Solution: Check your html code and fix errors in it, toolbar will appear
Upvotes: 4
Reputation: 95314
In order to have the Symfony2 debug toolbar shown in your rendered views you must pass thru a front-controller corresponding to an environment that has the toolbar enabled.
If you are using the standard distribution, only the "dev" environment has it enabled by default. Therefore you must use the app_dev.php
front-controller.
Upvotes: 0