Symfony2: access same route in production as development
Asked Answered
G

1

8

I'm developing a little application using Symfony2. I can access all routes with no problems in my dev environment:

http://symfony/app_dev.php/cp ("symfony" is in my hosts file to resolve to localhost)

However, as soon as I try and access it in the production environment, I just get a 404 error page:

http://symfony/app.php/cp

Oops! An Error Occurred The server returned a "404 Not Found". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

Is there something I need to change/do before I can view my application in production? I've not messed with any of the core files (kernel/bootstrap/app files, etc). I'm using Release Candidate 3.

Guttle answered 8/7, 2011 at 22:22 Comment(4)
Have you tried to clear the cache? (./app/console cache:clear or simply delete prod directory form ./app/cache)Mabuse
Thanks, that did it! Do you know why that would fix the problem? I'm really curious.Guttle
Presumably because your cache was generated before you added the cp route. The production cache won't regenerate itself automatically, so if you add or change any code, you need to clear it to see the changes on prod.Saltern
@Mabuse post your comment as answer so this question can be marked answered?Saltern
M
16

As Crozin already mentioned in his comment, you have to rebuild cache to be able to see your changes. You need to rebuild production cache every time you change something in config, routing or templates. The safest way to do so is using php app/console cache:clear --env=prod --no-debug (as CLI runs in dev mode with debugging enabled by default).

Machiavellian answered 16/10, 2011 at 18:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.