简体   繁体   中英

Symfony environments and debug bar

I am new to Symfony. Been doing some tests (Symfony 2.0.13 with php5.3.8 in WAMP2.2) and reading the documentation but I am kind of confused with environments.

When I go to LOCALHOST/Symfony/web/app_dev.php/demo/hello/Foo (app_dev means development environment, right?) I can see the web debug toolbar and clicking in the profiler info, in the "project configuration" tab, I can see: Environment dev

Now I go to LOCALHOST/Symfony/web/app.php/demo/hello/Foo and in the web debug toolbar (BTW, why I am seeing this toolbar now? Ain't this a production environment? Are my users supposed to see this bar by default?) I also see, in the "project configuration" tab: Environment dev

It seems that this "demo" Bundle is somehow associated with "dev", no matter what the URL is app_dev.php or app.php??

Moreover, I did some more tests: my local IP is 192.168.153.1.

When I try to access:

http://192.168.153.1/Symfony/web/app_dev.php/demo/hello/Foo

it says "You are not allowed to access this file. Check app_dev.php for more information." So, ok, if I edited the lines in app_dev.php and added my (external) IP, I could access.

BUT, when I connect to

http://192.168.153.1/Symfony/web/app.php/demo/hello/Foo

IT SAYS THE SAME! So it seems that my app.php is not being executed, and app_dev.php is being executed no matter what I type in the URL.

This is really confusing! I checked my htaccess and everything seems to be right.

Can anyone help me figure this out?

I have NOT modified the code for app_dev.php neither app.php, everything is just "as is" out of the box.


2012-05-02 EDIT

Something weird happened. I edited my config_prod.yml with these lines:

# load the profiler
framework:
    profiler: { only_exceptions: false }

# enable the web profiler
web_profiler:
    toolbar: true
    intercept_redirects: true
    verbose: true

Saved, and then edited the app.php file. Wanted to test what happened if I changed:

$kernel = new AppKernel('prod', false); //Symfony default

To

$kernel = new AppKernel('prod', true);

When I went to app.php/WHATEVER, an error page appeared, so I reverted all changes, restarted Apache and now the WebDebug Toolbar is not showing anymore in PROD (app.php/WHATEVER)

So, I don't know how, but it seems to work as expected now, although the config_prod.yml file and the app.php are in the original state. It also allows me to connect with my external IP to app.php

REALLY weird...

Here is an answer for those who use the malformed template for output.

[Link removed for redirecting to spam website]

Just copied for you:

"Hi. You have to have proper HTML on the page you are viewing. I think the debug bar attaches itself just before the </body> . So if you have a page like this (see below) you should see the debug bar."

Code:

<html> <head>

</head> <body>

</body> </html>

You need to disable ip filtering in app_dev.php. And you will be able to see the debug bar from external ip.

Regards, Max

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM