Search code examples
phpsymfony-2.3symfony-routing

symfony2.3 routing doesn't work on prod env


I'm trying to create a /contact route on my website using symfony on windows environment. I added in the routing.yml file the routes like this:

fstn_venice_homepage:
resource: "@FstnVeniceBundle/Resources/config/routing.yml"
prefix:   /

fstn_venice_contact:
pattern:   /contact
defaults:  { _controller: FstnVeniceBundle:Contact:send }

I have enabled the prod env :$kernel = new AppKernel('prod', true); Trying to execute the page on prod_env: http://localhost/fstn/web/app_dev.php/contact return an 404 error but in dev_env it displays the contact page correctly. So that I try to debug the routes by: php app/console router:debug -e=prod and I get this:

Name Method Scheme Host Path fstn_venice_homepage ANY ANY ANY / fstn_venice_contact ANY ANY ANY /contact

I even try to clear the cache by using the Command line :

php .\app\console cache:clear --env=prod --no-debug and it doesn't display any errors but no luck to display contact page on prod environment. How can I fix this problem?

--edit--- I found the source of my error, actually I should use this path to work in prod env:http://localhost/fstn/web/app.php/contact but I used before http://localhost/fstn/web/contact to test.


Solution

  • Saying the kernel you want a prod environement $kernel = new AppKernel('prod', true); you tell him to forbid access to the dev url http://localhost/fstn/web/app_dev.php/contact.

    If you want to access to the prod url, replace app_dev.php with app.php. You can still let the kernel env configuration to dev, and test in prod environement. After every change, don't forget to clear your cache, and chmod it ;)