Php – symfony2 – how to switch from “dev” to “prod”

PHPsymfony

I downloaded symfony2 and I am able to run it starting from app_dev.php.

But when I start from app.php, then I get an error page 404.

app.php though is of course there and it gets executed.

The error happens apparently somewhere after the last line of code in app.php:

$kernel->handle(Request::createFromGlobals())->send();

I guess there is a switch somewhere I have to configure.

EDIT:

As suggested by GeLo I added the routing for the production version to app/config/routing.yml.

_welcome:
    resource: "@AcmeDemoBundle/Resources/config/routing.yml"
    prefix:     /

I created src/Acme/DemoBundle/Resources/config/routing.yml with content:

bla:
    pattern: /
    defaults: {_controller:AcmeDemoBundle:Demo:index}

In DemoController::indexAction() I placed a die(__FILE__);

nothing; I still get 404 from app.php !?

EDIT regarding the answer:

./app/console --env=prod cache:clear

did the trick. mind the env-parameter.

Best Answer

By default, Symfony 2 is delivered with a demo bundle which is just accessible from the development environment.

The production environment doesn't contain any route, so it's normal you get a 404 error page.

EDIT :

Are you sure your bundle is enable in the AppKernel.php ?

If yes, clear the cache with the following command : ./app/console cache:clear

Check if the route is enable with the following command : ./app/console router:debug