Symfony: generate prod-url in dev environment

I am wondering if you can choose the environment when creating URLs with the symfony routing component.

In the controller

$this->generateUrl($route, $params);

generates /in prod envrionment and /app_dev.phpin dev.

There does not seem to be a parameter for the environment so that you can create productive URLs in the dev environment. I just don't want to use something like str_replace all the time.

It would be great:

$this->generateUrl($route, $params, 'prod');

For your understanding, I am working on a cms project where I need to map uris to a database where they are stored without app_dev.php.

Any ideas?

+3
source share
2 answers

, , Context $baseUrl '' ( ) generateUrl reset - . RequestContext- > getBaseUrl , Url.

Urls app_dev app.php, AngularJS, URL-. , app_dev app.php, EventListener,

$this->router->getContext()->setBaseUrl('');
+2

app.php app_dev.php. , php , , .

, . .htaccess , , .

0

All Articles