Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: How do you handle debug code? Removing from production versus conditional execution Date: Fri, 3 May 2019 13:59:41 +0200 Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net cQjHNt1VpgCK6aPTjJC0AwxucUiZt7d0FhLmFj024kLaj/GOIZ Cancel-Lock: sha1:HQpmfmu73iqY+hUWatk/bP8UrR0= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.php:17912 On 03.05.19 03:00, Ryan wrote: > Perhaps an age old question, but how do you all deal with your debug > code? Do you remove it before deploying to production, if so how do > you make sure you remove it all without removing something important > that will break your code? Or do you use conditional execution such > as: > > if ($_ENV['DEGUG'] == true) { var_dump($data); } > > If so what condition are you using? An environment variable like > above, a constant defined elsewhere in a config file? > > I think conditional execution would be easier but question if having > to check if the debug code can run would slow down a production > server, but the question is how much overhead really does it take to > check $_ENV or a constant... > > So I am curious to see how others deal with this. I don't add "debug code" at all. I use a Debugger like xdebug which is supported in Visual Studio Code, PHPStorm etc. -- Arno Welzel https://arnowelzel.de