Skip to content

Commit

Permalink
Merge pull request #669 from zechdc/1.8/develop
Browse files Browse the repository at this point in the history
Add how to get the current environment your application is using
  • Loading branch information
WanWizard committed Feb 15, 2015
2 parents c0b6a10 + 347091f commit 5693488
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions general/environments.html
Expand Up @@ -218,6 +218,29 @@ <h3 id="env_oil">Set Environment when using Oil</h3>

<pre class="cli"><code><strong>C:\> </strong>set FUEL_ENV=production &amp;&amp; php oil -v</code></pre>

<h3 id="setting_env">Get Your Current Environment</h3>

<p>
You can retrieve the current environment programmatically using <strong>\Fuel::$env</strong>
</p>

<p class="note">Do not use <strong>$_SERVER['FUEL_ENV']</strong>. It will not work if you do not set the environment. Using $_SERVER is not reliable, because it might not be there, or it might be overridden in code (which makes it different from \Fuel::$env).</p>

<pre class="php"><code>
// comparing current appliation environment to a predefinded environment

if(\Fuel::$env == \Fuel::PRODUCTION)
{
//do something
}

// comparing current appliation environment to a custom environment
if(\Fuel::$env == "mike_dev")
{
//do something
}
</code></pre>

</div>

<footer>
Expand Down

0 comments on commit 5693488

Please sign in to comment.