Autarky\Application::setEnvironment PHP Метод

setEnvironment() публичный Метод

Set the environment of the application. Has to be called before boot().
public setEnvironment ( string $environment )
$environment string
    public function setEnvironment($environment)
    {
        if ($this->booting) {
            throw new \RuntimeException('Cannot set environment after application has booted');
        }
        if ($environment instanceof Closure) {
            $environment = call_user_func($environment);
        }
        if (!is_string($environment)) {
            throw new \InvalidArgumentException('Environment must be a string');
        }
        $this->environment = $environment;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->app = $this->createApplication();
     $this->app->setEnvironment('testing');
     $this->app->boot();
     $this->app->getErrorHandler()->setRethrow(true);
 }