How to find out if development mode is on?

What is the best way to find out if the development mode is on? At the moment we use the following code:

if (strpos(exec('./vendor/bin/laminas-development-mode status'), 'ENABLED') === false)

The problem we have now is that the code needs to run on Windows and Linux. Hence I was wondering if there is e.g. a global variable I could check or if any method could be called to find out.

Does anybody have a better solution?

If memory serves you are using MVC? In mezzio there is a top level config key ‘debug’. In mezzio.global.php ‘debug’ => false, and in /config development.config.php ‘debug’ => true. Which means you can check the value:
$debug = $container->get(‘config’)[‘debug’];

So in MVC just add a top level ‘debug’ or development_mode key and then override it in development mode and check the config.

Check the composer.json file script section. There are a number of commands there. The one you’re looking for has three commands.

// Disable development mode. For Production
composer development-disable  
// Enable development mode. For development
composer development-enable 
// Detail whether or not the application is in development mode.
composer development-status   

When enable development mode a file is added in the Laminas MVC in which you can add development Modules like Laminas Tools etc. Therefore, add development module in that file.

Yes, correct. We are using MVC. I hoped that there would be an already built in solution but this solution is good too. I will do it like this. Thanks for the solution.

As you can see from my initial message I am already using those commands. I have a very specific problem that a call to another API should not be made when in development mode. So I need a solution within my code to find out if we are in this mode.

Do you know that there are local and global files? They are there for a purpose. Maybe those are there just for fun.