Use different template templates for dev and prod

In symfony 2, I want a particular environment to use a specific layout, and another to use a different layout.

What would be the best way to do this?

To clarify, let's say I have a prod_one environment and a prod_two environment. The prod_one environment must use some specific header on the displayed html pages, while the prod_two environment requires that these headers not be set.

Thanks!

+6
source share
1 answer

In the controller, you can find out which environment is used using the getEnvironment kernel service method:

 $env = $this->get('kernel')->getEnvironment(); if ($env == "prod_one"){ //$response->header->set(...); //return $this->render(...); } else if ($env == "prod_two"){ // ... } 

In the branch: you can use the global waving variable - app.environment :

 {% if app.environment == 'prod_one' %} {# Content for prod_one env #} {% elseif app.environment == 'prod_two' %} {# Content for prod_two env #} {% endif %} 
+15
source

Source: https://habr.com/ru/post/908617/


All Articles