src/Environment.php
public static function create(
        string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []
    ): EnvironmentInterface
    {
        if (! $allowed) {
            $allowed = [
                self::ENV_PRODUCTION,
                self::ENV_STAGING,
                self::ENV_TESTING,
                self::ENV_DEVELOPMENT,
            ];
        }

        $projectRoot = realpath($projectRoot);

        $filename = $projectRoot . '/.environment';
        if (! $projectRoot || ! file_exists($filename)) {
            return new static($default, $projectRoot);
        }

        // get the environment name
        $name = file_get_contents($filename);

        if (! in_array($name, $allowed)) {
            throw new UnknownEnvironmentException(
                'Unknown environment "' . $name . '". Either add to the allowed list or provide one of: '
                . join(', ', $allowed)
            );
        }

        return new static($name, $projectRoot);
    }
public static function create(
        string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []
    ): EnvironmentInterface
    {
        if (! $allowed) {
            $allowed = [
                self::ENV_PRODUCTION,
                self::ENV_STAGING,
                self::ENV_TESTING,
                self::ENV_DEVELOPMENT,
            ];
        }

        $projectRoot = realpath($projectRoot);

        $filename = $projectRoot . '/.environment';
        if (! $projectRoot || ! file_exists($filename)) {
            return new static($default, $projectRoot);
        }

        // get the environment name
        $name = file_get_contents($filename);

        if (! in_array($name, $allowed)) {
            throw new UnknownEnvironmentException(
                'Unknown environment "' . $name . '". Either add to the allowed list or provide one of: '
                . join(', ', $allowed)
            );
        }

        return new static($name, $projectRoot);
    }
public static function create ( string $ projectRoot , $ default = self :: ENV_PRODUCTION , array $ allowed = [ ] ) : EnvironmentInterface { if ( ! $ allowed ) { $ allowed = [ self :: ENV_PRODUCTION , self :: ENV_STAGING , self :: ENV_TESTING , self :: ENV_DEVELOPMENT , ] ; } $ projectRoot = realpath ( $ projectRoot ) ; $ filename = $ projectRoot . '/.environment' ; if ( ! $ projectRoot || ! file_exists ( $ filename ) ) { return new static ( $ default , $ projectRoot ) ; } // get the environment name $ name = file_get_contents ( $ filename ) ; if ( ! in_array ( $ name , $ allowed ) ) { throw new UnknownEnvironmentException ( 'Unknown environment "' . $ name . '". Either add to the allowed list or provide one of: ' . join ( ', ' , $ allowed ) ) ; } return new static ( $ name , $ projectRoot ) ; }
Create the environment using the default params and by searching the .environment file.

@param string $projectRoot
@param string $default
@param array $allowed
@return EnvironmentInterface
Create the environment using the default params and by searching the . environment file .