本文整理汇总了PHP中Illuminate\Container\Container::runningInConsole方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::runningInConsole方法的具体用法?PHP Container::runningInConsole怎么用?PHP Container::runningInConsole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Container\Container
的用法示例。
在下文中一共展示了Container::runningInConsole方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRunningEligibility
/**
* Checks the web eligibility for Platform. If true, Platform
* is safe to run in the web.
*
* @return bool
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function checkRunningEligibility()
{
// If we're running in console, we're always fine to
// run Platform except for testing.
if ($this->app->runningInConsole()) {
return $this->app->environment() !== 'testing';
}
if ($this->isInstalled()) {
// Now, let's check for database connectivity. If we have no
// connectivity, the database connection is probably lost.
// This means the service is in fact unavailable.
try {
$this->app['db']->connection();
return true;
} catch (PDOException $e) {
throw new HttpException(503, 'Database connection could not be established.');
}
}
// Check if the path is on the eligibility whitelist
return in_array($this->app['request']->path(), $this->eligibilityWhitelist);
}
示例2: isTestingEnviroment
/**
* Returns flag on testing enviroment
*
* @return bool
*/
public function isTestingEnviroment()
{
return $this->app->runningInConsole() && $this->app->environment() === 'testing';
}