A simple boolean detector that can be used to test which environment the application is running under. For example `Environment::is('development')` will return `true` if `'development'` is, in fact, the current environment.
This method also handles how the environment is detected at the beginning of the request. While the default detection rules are very simple (if the `'SERVER_ADDR'` variable is set to `127.0.0.1`, the environment is assumed to be `'development'`, or if the string `'test'` is found anywhere in the host name, it is assumed to be `'test'`, and in all other cases it is assumed to be `'production'`), you can define your own detection rule set easily using a closure that accepts an instance of the `Request` object, and returns the name of the correct environment, as in the following example: {{{ Environment::is(function($request) { if ($request->env('HTTP_HOST') == 'localhost') { return 'development'; } if ($request->env('HTTP_HOST') == 'staging.server') { return 'test'; } return 'production'; }); }}} In the above example, the user-specified closure takes in a `Request` object, and using the server data which it encapsulates, returns the correct environment name as a string.

Parameters

  • mixed $detect Either the name of an environment to check against the current, i.e. `'development'` or `'production'`, or a closure which `Environment` will use to determine the current environment name.

Returns

boolean If `$detect` is a string, returns `true` if the current environment matches the value of `$detect`, or `false` if no match. If used to set a custom detector, returns `null`.

Source

						public static function is($detect) {
		if (is_callable($detect)) {
			static::$_detector = $detect;
		}
		return (static::$_current == $detect);
	}