I don't know how everyone defines the running environment of their own projects. I am talking about the environment: Online (master), testing (beta), Development (dev), local (local) this is like setting the host of the machine. {code ...} I don't know what is better than this one... I don't know how everyone defines the running environment of their own projects. I am talking about the environment: Online (master), testing (beta), Development (dev), local (local) this is done by setting the host of the machine.
// Select if (gethostname () = 'tbj-test') {define ('env _ mode', 'dev');} elseif (gethostname () === 'tbjbeta ') {define ('env _ mode', 'beta');} elseif (strpos (gethostname (), 'tbj-') === 0) {define ('env _ mode', 'local');} else {define ('env _ mode', 'online ');}
I don't know what is better than this?
Reply content:
I don't know how everyone defines the running environment of their own projects. I am talking about the environment: Online (master), testing (beta), Development (dev), local (local) this is done by setting the host of the machine.
// Select if (gethostname () = 'tbj-test') {define ('env _ mode', 'dev');} elseif (gethostname () === 'tbjbeta ') {define ('env _ mode', 'beta');} elseif (strpos (gethostname (), 'tbj-') === 0) {define ('env _ mode', 'local');} else {define ('env _ mode', 'online ');}
I don't know what is better than this?
I have two solutions:
First, write it in the configuration file. However, this method is not easy to use, especially when the project has a version library that requires continuous integration, it will be more troublesome.
Second, it is identified by specific files. For example, there isrelease.lock
The program detects this file as an online version, and can ignore these identification files when entering the version library.
Almost, it is on the server, custom environment variables
For example, laravel is in the nginx configuration file.
fastcgi_param APP_ENV testing;
Then, the suffix of the. env file is loaded according to the environment variable, and The. env. testing configuration file is loaded.
So now we are more accustomed to using this form.