Jon
Jon

Reputation: 8531

Symfony 2 - getEnvorinment() in Prod

I am trying to test what the code below would dump in my various environments (local, dev, qa, int). By adding /app_dev.php/ and /app_qa.php/ after the domain, I am able to determine that Symfony outputs 'dev' and 'qa' respectably. When I try /app_prod.php/ to simulate my INT environment, I get a server error message.

I want to confirm that using the code below on a prod environment would dump 'prod'.

var_dump( $this->container->get('kernel')->getEnvironment() );

Upvotes: 1

Views: 556

Answers (1)

Ghassan Idriss
Ghassan Idriss

Reputation: 2118

$this->container->get('kernel')->getEnvironment() will return the value of the first argument of AppKernel when the framework is loaded.

$kernel = new AppKernel('prod', false);

getEnvironment() returns prod

$kernel = new AppKernel('qa', false);

getEnvironment() returns qa

Upvotes: 4

Related Questions