Symfony2 fresh installation test : app_dev.php works but app.php get redirection. Why prod doesn’t work

symfony

I installed latest symfony2 and follow the book to install and setup everything.

Xampp is in /opt/lampp,
symfony2 is in my home dir ~/proj/symfony2.

I made a symbol link /opt/lampp/htdocs/symfony2 => ~/proj/symfony2.

In browser, I type in "localhost/symfony2/web/app_dev.php". It works! the page shows up.

But if I used app.php instead, browser will be redirected to /opt/lampp/htdocs/index.

If I copy app_dev.php to app.php, still doesn't work!!! Why this happens?

If I copy app_dev.php to app_test.php and use "localhost/symfony2/web/app_test.php". It works!

I really don't know why it is so hard to make prod work in symfony2.

I read a lot of post about app.php get 404 error. And try clear, warmup, dump….nothing help.

I know acmedemo is for debug only. But how to test prod out of box? I do this because I follow book to write a acme hello but didn't work in prod. I put it to app_dev.php, didn't work.

app/prod.log: could be the reason?

request.ERROR: Uncaught PHP Exception
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No
route found for "GET /bundles/framework/images/input_bg.gif"" at
/…/symfony2/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php
line 94 [] []

Best Answer

The Symfony2 Standard Edition comes with a complete demo that lives inside a bundle called AcmeDemoBundle.

This bundle available only for dev environment:

AppKernel.php

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();

routing_dev.yml:

_welcome:
    pattern:  /
    defaults: { _controller: AcmeDemoBundle:Welcome:index }

You should:

1) remove the AcmeDemoBundle http://symfony.com/doc/2.2/cookbook/bundles/remove.html

2) generating a new bundle http://symfony.com/doc/master/bundles/SensioGeneratorBundle/commands/generate_bundle.html

http://symfony.com/doc/master/book/routing.html

Related Topic