当前位置: 首页>>代码示例>>PHP>>正文


PHP App::runningInConsole方法代码示例

本文整理汇总了PHP中App::runningInConsole方法的典型用法代码示例。如果您正苦于以下问题:PHP App::runningInConsole方法的具体用法?PHP App::runningInConsole怎么用?PHP App::runningInConsole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::runningInConsole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     \Event::fire('press.mount', []);
     if (\App::runningInConsole()) {
         $this->consoleSetup();
     }
 }
开发者ID:lud,项目名称:press,代码行数:12,代码来源:PressServiceProvider.php

示例2: saving

 public function saving($details)
 {
     // Level is not enough
     if ($details->user->role->level > LEVEL and !\App::runningInConsole()) {
         $this->setFlashError('alert.error.user_updated');
         return false;
     }
 }
开发者ID:pongocms,项目名称:cms,代码行数:8,代码来源:UserDetailObserver.php

示例3: __construct

 public function __construct()
 {
     if (\App::runningInConsole()) {
         $this->request = [];
     } else {
         $this->request = ['url' => request()->url(), 'method' => request()->method(), 'input' => request()->input(), 'action' => \Route::getCurrentRoute() !== null ? \Route::getCurrentRoute()->getAction() : null, 'headers' => request()->header()];
     }
 }
开发者ID:lsrur,项目名称:inspector,代码行数:8,代码来源:RequestCollector.php

示例4: boot

 public function boot()
 {
     if (!\App::runningInConsole()) {
         $menu = file(base_path() . '/resources/content/menu.md', FILE_IGNORE_NEW_LINES);
         sort($menu);
         view()->share('menu', $menu);
     }
 }
开发者ID:JayBizzle,项目名称:awesomephp.io,代码行数:8,代码来源:AppServiceProvider.php

示例5: _e

 public function _e($text, $toLog = false)
 {
     if (\App::runningInConsole()) {
         //			$this->error($text);
     }
     if ($toLog) {
         \Log::error($text);
     }
 }
开发者ID:stels-cs,项目名称:tinder-olega,代码行数:9,代码来源:AbstractCommand.php

示例6: __construct

 public function __construct(\Exception $exception, $httpCode)
 {
     if (\App::runningInConsole()) {
         // no cli
         return;
     }
     $this->exception = $exception;
     $this->httpCode = $httpCode;
     $this->title = __('Un problème est survenu');
 }
开发者ID:stanmay,项目名称:unflare,代码行数:10,代码来源:ExceptionsHandler.php

示例7: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     \App::make('router')->middleware('artificer-installed', InstalledMiddleware::class);
     // Avoid redirection when using CLI
     if (\App::runningInConsole() || \App::runningUnitTests()) {
         return true;
     }
     if (!self::isInstalling() && !self::isInstalled()) {
         $this->goToInstall();
     }
 }
开发者ID:marcmascarell,项目名称:laravel-artificer,代码行数:16,代码来源:InstallServiceProvider.php

示例8: register

 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     if ($this->app->environment() === 'local') {
         $this->app->register(GeneratorsServiceProvider::class);
         $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
     }
     $this->app->singleton(ValidationInterface::class, IlluminateValidation::class);
     if ($this->app->environment() === 'local' && \App::runningInConsole()) {
         $this->app->register(ArtisanBeansServiceProvider::class);
         $this->app->register(IdeHelperServiceProvider::class);
     }
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:17,代码来源:AppServiceProvider.php

示例9: terminate

 public function terminate($request, $response)
 {
     if (!\App::runningInConsole() && \App::bound('veer') && app('veer')->isBooted()) {
         $timeToLoad = empty(app('veer')->statistics['loading']) ? 0 : app('veer')->statistics['loading'];
         if ($timeToLoad > config('veer.loadingtime')) {
             \Log::alert('Slowness detected: ' . $timeToLoad . ': ', app('veer')->statistics());
             info('Queries: ', \DB::getQueryLog());
         }
         \Veer\Jobs\TrackingUser::run();
         (new \Veer\Commands\HttpQueueWorkerCommand(config('queue.default')))->handle();
     }
 }
开发者ID:artemsk,项目名称:veer-core,代码行数:12,代码来源:ShutdownMiddleware.php

示例10: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     try {
         $this->bootStore($this->app['App\\Store']);
         $this->bootTheme($this->app['App\\Theme'], $this->app['App\\Store']);
     } catch (QueryException $e) {
         // missing core tables
         if (!\App::runningInConsole()) {
             throw new HttpException(500, "Lavender not installed.");
         }
     } catch (\Exception $e) {
         // something went wrong
         if (!\App::runningInConsole()) {
             throw new HttpException(500, $e->getMessage());
         }
     }
 }
开发者ID:BryceHappy,项目名称:lavender,代码行数:22,代码来源:AppServiceProvider.php

示例11: __construct

 public function __construct(Migrator $migrator, MigrationRepositoryInterface $repository)
 {
     $commands = [];
     foreach ($this->commands as $command) {
         if ($command == InstallCommand::class) {
             $instance = new $command($repository);
         } else {
             $instance = new $command($migrator);
         }
         $instance->setName('artificer:' . $instance->getName());
         $commands[] = $instance;
     }
     /*
      * Only allow this commands via UI to avoid some inconsistencies
      */
     if (!\App::runningInConsole()) {
         $this->registerCommands($commands);
     }
 }
开发者ID:marcmascarell,项目名称:laravel-artificer,代码行数:19,代码来源:MigrationCommands.php

示例12: __construct

 /**
  * @param \Illuminate\Contracts\Foundation\Application $app
  */
 public function __construct($app)
 {
     // detect site section and make its service provider and import
     /** @var AppSiteLoaderInterface|AppSiteLoader $className */
     foreach ($this->additionalSectionLoaderClasses as $className) {
         if ($className::canBeUsed()) {
             static::$siteLoader = new $className($this, $app);
             break;
         }
     }
     if (static::$siteLoader === null) {
         if ($this->consoleSectionLoaderClass !== null && \App::runningInConsole()) {
             $className = $this->consoleSectionLoaderClass;
         } else {
             $className = $this->defaultSectionLoaderClass;
         }
         static::$siteLoader = new $className($this, $app);
     }
     parent::__construct($app);
 }
开发者ID:swayok,项目名称:laravel-site-loader,代码行数:23,代码来源:AppSitesServiceProvider.php

示例13: dd

 /**
  * Show inspector full screen page and die
  * @return [type] [description]
  */
 public function dd($status = 206, $analizeResponse = false)
 {
     // Try to take these values as soon as posible
     $time = microtime(true);
     $memoryUsage = formatMemSize(memory_get_usage());
     // CLI response
     if (\App::runningInConsole()) {
         $result = $this->collectorMan->getRaw();
         dump($result);
         return;
     }
     // Json respnse
     if (request()->wantsJson()) {
         $title = $status == 206 ? 'DD' : "UNCAUGHT EXCEPTION";
         header("status: {$status}", true);
         header("Content-Type: application/json", true);
         $collectorData = request()->headers->has('laravel-inspector') ? $this->collectorMan->getScripts('inspector', $title, $status) : $this->collectorMan->getPreJson('inspector');
         if ($analizeResponse) {
             // Respond the payload also
             $collectorData = array_merge(json_decode($this->response->getContent(), true), ['LARAVEL_INSPECTOR' => $collectorData]);
         } else {
             $collectorData = ['LARAVEL_INSPECTOR' => $collectorData];
         }
         echo json_encode($collectorData);
         die;
     } else {
         // Fullscreen dd
         // Get collectors bag ready for fullscreen view
         $collectorData = $this->collectorMan->getFs();
         try {
             $view = (string) view('inspector::fullscreen', ['analizeView' => $analizeResponse, 'collectors' => $collectorData, 'memoryUsage' => $memoryUsage, 'time' => round(($time - LARAVEL_START) * 1000, 2)]);
             echo $view;
             die;
         } catch (\Exception $e) {
             dump($e);
             die;
         }
     }
 }
开发者ID:lsrur,项目名称:inspector,代码行数:43,代码来源:Inspector.php

示例14: id

 public function id()
 {
     if (app()->runningInConsole()) {
         return null;
     }
     //1. get current host
     $host = $this->host(true);
     //2. see if we already know the site ID from this host in the cache
     $cacheKey = 'site_id_' . $host;
     $siteId = Cache::get($cacheKey);
     //3. if we couldn't find an entry in the cache, find the site ID via the database
     if (empty($siteId)) {
         $siteId = $this->getSiteIdFromDatabase($host);
     }
     //4. throw an exception if we couldn't find the site ID in the database
     if (empty($siteId) && !\App::runningInConsole()) {
         $error = 'Host was not defined as a site on the database level: ' . $host;
         throw new \Exception($error);
     }
     //5. Keep the siteId in the cache!
     $expiresAt = Carbon::now()->addMinutes(10);
     Cache::put($cacheKey, $siteId, $expiresAt);
     return $siteId;
 }
开发者ID:bitsoflove,项目名称:Site,代码行数:24,代码来源:SiteGateway.php

示例15: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->publishes([__DIR__ . '/../config/propel.php' => config_path('propel.php')]);
     if (!$this->app->config['propel.propel.runtime.connections']) {
         throw new \InvalidArgumentException('Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.');
     }
     // load pregenerated config
     if (file_exists(app_path() . '/propel/config.php')) {
         Propel::init(app_path() . '/propel/config.php');
         return;
     }
     // runtime configuration
     /** @var \Propel\Runtime\ServiceContainer\StandardServiceContainer */
     $serviceContainer = \Propel\Runtime\Propel::getServiceContainer();
     $serviceContainer->closeConnections();
     $serviceContainer->checkVersion('2.0.0-dev');
     $propel_conf = $this->app->config['propel.propel'];
     $runtime_conf = $propel_conf['runtime'];
     // set connections
     foreach ($runtime_conf['connections'] as $connection_name) {
         $config = $propel_conf['database']['connections'][$connection_name];
         if (!isset($config['classname'])) {
             if ($this->app->config['app.debug']) {
                 $config['classname'] = '\\Propel\\Runtime\\Connection\\DebugPDO';
             } else {
                 $config['classname'] = '\\Propel\\Runtime\\Connection\\ConnectionWrapper';
             }
         }
         $serviceContainer->setAdapterClass($connection_name, $config['adapter']);
         $manager = new \Propel\Runtime\Connection\ConnectionManagerSingle();
         $manager->setConfiguration($config + [$propel_conf['paths']]);
         $manager->setName($connection_name);
         $serviceContainer->setConnectionManager($connection_name, $manager);
     }
     $serviceContainer->setDefaultDatasource($runtime_conf['defaultConnection']);
     // set loggers
     $has_default_logger = false;
     if (isset($runtime_conf['log'])) {
         foreach ($runtime_conf['log'] as $logger_name => $logger_conf) {
             $serviceContainer->setLoggerConfiguration($logger_name, $logger_conf);
             $has_default_logger |= $logger_name === 'defaultLogger';
         }
     }
     if (!$has_default_logger) {
         $serviceContainer->setLogger('defaultLogger', \Log::getMonolog());
     }
     Propel::setServiceContainer($serviceContainer);
     $command = false;
     if (\App::runningInConsole()) {
         $input = new ArgvInput();
         $command = $input->getFirstArgument();
     }
     // skip auth driver adding if running as CLI to avoid auth model not found
     if ('propel:model:build' !== $command && 'propel' === \Config::get('auth.driver')) {
         $query_name = \Config::get('auth.user_query', false);
         if ($query_name) {
             $query = new $query_name();
             if (!$query instanceof Criteria) {
                 throw new InvalidConfigurationException("Configuration directive «auth.user_query» must contain valid classpath of user Query. Excpected type: instanceof Propel\\Runtime\\ActiveQuery\\Criteria");
             }
         } else {
             $user_class = \Config::get('auth.model');
             $query = new $user_class();
             if (!method_exists($query, 'buildCriteria')) {
                 throw new InvalidConfigurationException("Configuration directive «auth.model» must contain valid classpath of model, which has method «buildCriteria()»");
             }
             $query = $query->buildPkeyCriteria();
             $query->clear();
         }
         \Auth::extend('propel', function (\Illuminate\Foundation\Application $app) use($query) {
             return new PropelUserProvider($query, $app->make('hash'));
         });
     }
 }
开发者ID:Andrewwojownik,项目名称:propel-laravel,代码行数:79,代码来源:RuntimeServiceProvider.php


注:本文中的App::runningInConsole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。