Flarum\Foundation\Application::environment PHP Method

environment() public method

Get or check the current application environment.
public environment ( ) : string
return string
    public function environment()
    {
        if (func_num_args() > 0) {
            $patterns = is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args();
            foreach ($patterns as $pattern) {
                if (Str::is($pattern, $this['env'])) {
                    return true;
                }
            }
            return false;
        }
        return $this['env'];
    }

Usage Example

Example #1
0
 /**
  * @param Application $app
  */
 protected function registerLogger(Application $app)
 {
     $logger = new Logger($app->environment());
     $logPath = $app->storagePath() . '/logs/flarum.log';
     $handler = new StreamHandler($logPath, Logger::DEBUG);
     $handler->setFormatter(new LineFormatter(null, null, true, true));
     $logger->pushHandler($handler);
     $app->instance('log', $logger);
     $app->alias('log', 'Psr\\Log\\LoggerInterface');
 }