Generate production url in dev environment

Today another colleague asked me about a problem he had. Practically all the css and js link generated in dev environment didn’t have app_dev.php at the beginning of the url.

So we dived into the code and found out from one of the solutions he found in SO he set the base url of router context to empty which caused it to lose app_dev.php which is the base url in dev environment.

Well at the beginning I said just replace /app_dev.php with empty string but he said that wouldn’t look good which made sense.

There was no clear solution from symfony because basically you have no way in symfony to know how the production url work for different applications.

The best and cleanest solution was to practically remove anything that has .php and starts with /

So far I think this is the cleanest solution you can have.

The only case that this can fail is when for example you are passing a php file name in the url which I don’t think anyone even think about it 😀


j j j