symfony2 - how to switch from “dev” to “prod”?

后端 未结 6 2238
再見小時候
再見小時候 2020-12-04 10:53

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 co

6条回答
  •  醉梦人生
    2020-12-04 11:29

    I just wanted to integrate a couple of tips for this kind of problem since I faced it nowadays with a new fresh Symfony2 installation.

    As a fresh installation you normally get AppBundle under /src/AppBundle together with AcmeDemoBundle under /src/Acme/DemoBundle

    If you want to run AcmeDemoBundle on app_dev and, in the meanwhile, have an application ( i.e. AppBundle provided with fresh installation ) on app.php ( and avoid 404 ) you can also do something like that:

    in /app/config/routing_dev.yml comment the following rows ( if you have them ):

    _main:
        resource: routing.yml
    

    in /app/config/routing.yml add a new route ( if you don't have )

    index:
        pattern:  /
        defaults: { _controller: AppBundle:Default:index }
    

    then empty cache like already advised by the others and test the application on


    1) http:// your_application_path/web/


    2) http:// your_application_path/web/app_dev.php

    If everything is fine on the first one you should get a white page with a string "Homepage." ( to edit this one go in /app/Resources/views/default/index.html.twig... Layout for this one is base.html.twig ) and, on the second one you should get the DemoBundle provided by Symfony2.

    Hope it helps!

提交回复
热议问题