PHP - disabling classes that are only needed in development
<p>I am writing a small script in PHP and am using a Profiler for the development zone to see which functions/actions are slow etc. </p>

<pre><code>$this-&gt;profiler = new \Fabfuel\Prophiler\Profiler();
</code></pre>

<p>Then I am using it in different methods all over the place (passing it via DI, using League\Container\Container class):</p>

<pre><code>$profilerSeg = $profiler-&gt;profilerStartSegment('Page Load','CMS');
...
$profiler-&gt;profilerStopSegment($profilerSeg);
</code></pre>

<p>Problem is, I only want to use this in development. Thought about an IF statement:</p>

<pre><code>if($this-&gt;environment === 'DEV')
    $profilerSeg = $profiler-&gt;profilerStartSegment('Page Load','CMS');
...
if($this-&gt;environment === 'DEV')
    $profiler-&gt;profilerStopSegment($profilerSeg);
</code></pre>

<p>but it looks ugly to have it everywhere. Then I thought about making a "fake profiler" that gets passed if the script is in production so all the calls would return NULL.</p>

<p>What is the best way to handle such a case: a class needed only in development but that should not be loaded in production?</p>