I work with two application servers on a daily basis: one development, one production. A variety of apps from different developers live on these boxes, as well as some scripts that run via cron. Currently, I am using the -D
flag to httpd so that I can identify my production server in code, ie. isset($_SERVER['DEV'])
. Unfortunately, this does not work for scripts run from the command line since they're not under the Apache umbrella.
Essentially, I would like a clean, simple way to identify development vs. production that is available to every line of code.
What I have ruled out:
auto_prepend_file
-- we are already using this directive in some applications, and you can't have more than one autoprepend.What I am currently exploring:
So, got any tricks for identifying dev/prod that doesn't involve injecting code into every script or application?
Typically, a server in a development environment allows unrestricted access to and control by a user or group of users. A production server, on the other hand, is configured to restrict access to authorized users and to limit control to system administrators.
Production and non-production environments are logically and physically separated. The development, quality assurance, and production environments use separate equipment and environments, which are managed separately. Production data is not replicated or used in non-production environments.
In the Control Panel window, double-click System. In the System Properties dialog box, choose the Environment tab. Check to see if the value of system environment variable TZ is JST-9.
A development server is a type of server that is designed to facilitate the development and testing of programs, websites, software or applications for software programmers. It provides a run-time environment, as well as all hardware/software utilities that are essential to program debugging and development.
Just set an environment variable. It works on Windows and linux, they are even called the same thing now. Then just check $_ENV["DEVVSPROD"]
I usually just do something like this:
if ($_SERVER['HTTP_HOST'] == 'localhost') // or any other host { // development } else { // production }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With