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


PHP Application::booted方法代码示例

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


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

示例1: mergeDefaults

 protected function mergeDefaults($key, $config, $method)
 {
     $config = is_array($config) ? $config : config($config, []);
     $this->app->booted(function ($app) use($key, $config, $method) {
         $app['codex']->setConfig($key, call_user_func_array($method, [$app['codex']->config($key), $config]));
     });
 }
开发者ID:codexproject,项目名称:core,代码行数:7,代码来源:Factory.php

示例2: boot

 /**
  * Boot the debugbar (add collectors, renderer and listener)
  */
 public function boot()
 {
     if ($this->booted) {
         return;
     }
     $debugbar = $this;
     $app = $this->app;
     if ($this->app['config']->get('laravel-debugbar::config.storage.enabled')) {
         $path = $this->app['config']->get('laravel-debugbar::config.storage.path');
         $storage = new FilesystemStorage($this->app['files'], $path);
         $debugbar->setStorage($storage);
     }
     if ($this->shouldCollect('phpinfo', true)) {
         $this->addCollector(new PhpInfoCollector());
     }
     if ($this->shouldCollect('messages', true)) {
         $this->addCollector(new MessagesCollector());
     }
     if ($this->shouldCollect('time', true)) {
         $this->addCollector(new TimeDataCollector());
         $this->app->booted(function () use($debugbar) {
             if (defined('LARAVEL_START')) {
                 $debugbar['time']->addMeasure('Booting', LARAVEL_START, microtime(true));
             }
         });
         //Check if App::before is already called..
         if (version_compare($app::VERSION, '4.1', '>=') && $this->app->isBooted()) {
             $debugbar->startMeasure('application', 'Application');
         } else {
             $this->app->before(function () use($debugbar) {
                 $debugbar->startMeasure('application', 'Application');
             });
         }
         $this->app->after(function () use($debugbar) {
             $debugbar->stopMeasure('application');
             $debugbar->startMeasure('after', 'After application');
         });
     }
     if ($this->shouldCollect('memory', true)) {
         $this->addCollector(new MemoryCollector());
     }
     if ($this->shouldCollect('exceptions', true)) {
         try {
             $exceptionCollector = new ExceptionsCollector();
             if (method_exists($exceptionCollector, 'setChainExceptions')) {
                 $exceptionCollector->setChainExceptions($this->app['config']->get('laravel-debugbar::config.options.exceptions.chain', true));
             }
             $this->addCollector($exceptionCollector);
             $this->app->error(function (Exception $exception) use($exceptionCollector) {
                 $exceptionCollector->addException($exception);
             });
         } catch (\Exception $e) {
         }
     }
     if ($this->shouldCollect('laravel', false)) {
         $this->addCollector(new LaravelCollector($this->app));
     }
     if ($this->shouldCollect('default_request', false)) {
         $this->addCollector(new RequestDataCollector());
     }
     if ($this->shouldCollect('events', false) and isset($this->app['events'])) {
         try {
             $this->addCollector(new MessagesCollector('events'));
             $dispatcher = $this->app['events'];
             $dispatcher->listen('*', function () use($debugbar, $dispatcher) {
                 if (method_exists($dispatcher, 'firing')) {
                     $event = $dispatcher->firing();
                 } else {
                     $args = func_get_args();
                     $event = end($args);
                 }
                 $debugbar['events']->info("Received event: " . $event);
             });
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add EventCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('views', true) and isset($this->app['events'])) {
         try {
             $collectData = $this->app['config']->get('laravel-debugbar::config.options.views.data', true);
             $this->addCollector(new ViewCollector($collectData));
             $this->app['events']->listen('composing:*', function ($view) use($debugbar) {
                 $debugbar['views']->addView($view);
             });
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('route')) {
         try {
             if (version_compare($app::VERSION, '4.1', '>=')) {
                 $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\IlluminateRouteCollector'));
             } else {
                 $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\SymfonyRouteCollector'));
             }
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add RouteCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
//.........这里部分代码省略.........
开发者ID:cenwj,项目名称:sns,代码行数:101,代码来源:LaravelDebugBar.php

示例3: booted

 /**
  * Register a new "booted" listener.
  *
  * @param mixed $callback
  * @return void 
  * @static 
  */
 public static function booted($callback)
 {
     \Illuminate\Foundation\Application::booted($callback);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例4: boot

 /**
  * Boot the debugbar (add collectors, renderer and listener)
  */
 public function boot()
 {
     if ($this->booted) {
         return;
     }
     if ($this->isDebugbarRequest()) {
         $this->app['session']->reflash();
     }
     /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
     $debugbar = $this;
     /** @var Application $app */
     $app = $this->app;
     $this->selectStorage($debugbar);
     if ($this->shouldCollect('phpinfo', true)) {
         $this->addCollector(new PhpInfoCollector());
     }
     if ($this->shouldCollect('messages', true)) {
         $this->addCollector(new MessagesCollector());
     }
     if ($this->shouldCollect('time', true)) {
         $startTime = defined('LARAVEL_START') ? LARAVEL_START : null;
         $this->addCollector(new TimeDataCollector($startTime));
         if ($this->isLumen()) {
             $debugbar->startMeasure('application', 'Application');
         } else {
             $this->app->booted(function () use($debugbar, $startTime) {
                 if ($startTime) {
                     $debugbar['time']->addMeasure('Booting', $startTime, microtime(true));
                 }
             });
             //Check if App::before is already called..
             if ($this->app->isBooted()) {
                 $debugbar->startMeasure('application', 'Application');
             } else {
                 $this->app['router']->before(function () use($debugbar) {
                     $debugbar->startMeasure('application', 'Application');
                 });
             }
             $this->app['router']->after(function () use($debugbar) {
                 $debugbar->stopMeasure('application');
                 $debugbar->startMeasure('after', 'After application');
             });
         }
     }
     if ($this->shouldCollect('memory', true)) {
         $this->addCollector(new MemoryCollector());
     }
     if ($this->shouldCollect('exceptions', true)) {
         try {
             $exceptionCollector = new ExceptionsCollector();
             $exceptionCollector->setChainExceptions($this->app['config']->get('debugbar.options.exceptions.chain', true));
             $this->addCollector($exceptionCollector);
         } catch (\Exception $e) {
         }
     }
     if ($this->shouldCollect('laravel', false)) {
         $this->addCollector(new LaravelCollector($this->app));
     }
     if ($this->shouldCollect('default_request', false)) {
         $this->addCollector(new RequestDataCollector());
     }
     if ($this->shouldCollect('events', false) && isset($this->app['events'])) {
         try {
             $startTime = defined('LARAVEL_START') ? LARAVEL_START : null;
             $eventCollector = new EventCollector($startTime);
             $this->addCollector($eventCollector);
             $this->app['events']->subscribe($eventCollector);
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add EventCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('views', true) && isset($this->app['events'])) {
         try {
             $collectData = $this->app['config']->get('debugbar.options.views.data', true);
             $this->addCollector(new ViewCollector($collectData));
             $this->app['events']->listen('composing:*', function ($view) use($debugbar) {
                 $debugbar['views']->addView($view);
             });
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if (!$this->isLumen() && $this->shouldCollect('route')) {
         try {
             $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\IlluminateRouteCollector'));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add RouteCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if (!$this->isLumen() && $this->shouldCollect('log', true)) {
         try {
             if ($this->hasCollector('messages')) {
                 $logger = new MessagesCollector('log');
                 $this['messages']->aggregate($logger);
                 $this->app['log']->listen(function ($level, $message, $context) use($logger) {
                     try {
                         $logMessage = (string) $message;
//.........这里部分代码省略.........
开发者ID:crstestacc,项目名称:laravel-debugbar,代码行数:101,代码来源:LaravelDebugbar.php

示例5: boot

 /**
  * Boot the debugbar (add collectors, renderer and listener)
  */
 public function boot()
 {
     if ($this->booted) {
         return;
     }
     /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
     $debugbar = $this;
     /** @var Application $app */
     $app = $this->app;
     $this->selectStorage($debugbar);
     if ($this->shouldCollect('phpinfo', true)) {
         $this->addCollector(new PhpInfoCollector());
     }
     if ($this->shouldCollect('messages', true)) {
         $this->addCollector(new MessagesCollector());
     }
     if ($this->shouldCollect('time', true)) {
         $this->addCollector(new TimeDataCollector());
         if (!$this->isLumen()) {
             $this->app->booted(function () use($debugbar) {
                 $startTime = $this->app['request']->server('REQUEST_TIME_FLOAT');
                 if ($startTime) {
                     $debugbar['time']->addMeasure('Booting', $startTime, microtime(true));
                 }
             });
         }
         $debugbar->startMeasure('application', 'Application');
     }
     if ($this->shouldCollect('memory', true)) {
         $this->addCollector(new MemoryCollector());
     }
     if ($this->shouldCollect('exceptions', true)) {
         try {
             $exceptionCollector = new ExceptionsCollector();
             $exceptionCollector->setChainExceptions($this->app['config']->get('debugbar.options.exceptions.chain', true));
             $this->addCollector($exceptionCollector);
         } catch (\Exception $e) {
         }
     }
     if ($this->shouldCollect('laravel', false)) {
         $this->addCollector(new LaravelCollector($this->app));
     }
     if ($this->shouldCollect('default_request', false)) {
         $this->addCollector(new RequestDataCollector());
     }
     if ($this->shouldCollect('events', false) && isset($this->app['events'])) {
         try {
             $startTime = $this->app['request']->server('REQUEST_TIME_FLOAT');
             $eventCollector = new EventCollector($startTime);
             $this->addCollector($eventCollector);
             $this->app['events']->subscribe($eventCollector);
         } catch (\Exception $e) {
             $this->addThrowable(new Exception('Cannot add EventCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('views', true) && isset($this->app['events'])) {
         try {
             $collectData = $this->app['config']->get('debugbar.options.views.data', true);
             $this->addCollector(new ViewCollector($collectData));
             $this->app['events']->listen('composing:*', function ($view) use($debugbar) {
                 $debugbar['views']->addView($view);
             });
         } catch (\Exception $e) {
             $this->addThrowable(new Exception('Cannot add ViewCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if (!$this->isLumen() && $this->shouldCollect('route')) {
         try {
             $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\IlluminateRouteCollector'));
         } catch (\Exception $e) {
             $this->addThrowable(new Exception('Cannot add RouteCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if (!$this->isLumen() && $this->shouldCollect('log', true)) {
         try {
             if ($this->hasCollector('messages')) {
                 $logger = new MessagesCollector('log');
                 $this['messages']->aggregate($logger);
                 $this->app['log']->listen(function ($level, $message, $context) use($logger) {
                     try {
                         $logMessage = (string) $message;
                         if (mb_check_encoding($logMessage, 'UTF-8')) {
                             $logMessage .= !empty($context) ? ' ' . json_encode($context) : '';
                         } else {
                             $logMessage = "[INVALID UTF-8 DATA]";
                         }
                     } catch (\Exception $e) {
                         $logMessage = "[Exception: " . $e->getMessage() . "]";
                     }
                     $logger->addMessage('[' . date('H:i:s') . '] ' . "LOG.{$level}: " . $logMessage, $level, false);
                 });
             } else {
                 $this->addCollector(new MonologCollector($this->app['log']->getMonolog()));
             }
         } catch (\Exception $e) {
             $this->addThrowable(new Exception('Cannot add LogsCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
//.........这里部分代码省略.........
开发者ID:barryvdh,项目名称:laravel-debugbar,代码行数:101,代码来源:LaravelDebugbar.php

示例6: boot

 /**
  * Boot the debugbar (add collectors, renderer and listener)
  */
 public function boot()
 {
     if ($this->booted) {
         return;
     }
     $debugbar = $this;
     $app = $this->app;
     if ($this->app['config']->get('laravel-debugbar::config.storage.enabled')) {
         $path = $this->app['config']->get('laravel-debugbar::config.storage.path');
         $storage = new FilesystemStorage($this->app['files'], $path);
         $debugbar->setStorage($storage);
     }
     if ($this->shouldCollect('phpinfo', true)) {
         $this->addCollector(new PhpInfoCollector());
     }
     if ($this->shouldCollect('messages', true)) {
         $this->addCollector(new MessagesCollector());
     }
     if ($this->shouldCollect('time', true)) {
         $this->addCollector(new TimeDataCollector());
         $this->app->booted(function () use($debugbar) {
             if (defined('LARAVEL_START')) {
                 $debugbar['time']->addMeasure('Booting', LARAVEL_START, microtime(true));
             }
         });
         //Check if App::before is already called..
         if (version_compare($app::VERSION, '4.1', '>=') && $this->app->isBooted()) {
             $debugbar->startMeasure('application', 'Application');
         } else {
             $this->app->before(function () use($debugbar) {
                 $debugbar->startMeasure('application', 'Application');
             });
         }
         $this->app->after(function () use($debugbar) {
             $debugbar->stopMeasure('application');
             $debugbar->startMeasure('after', 'After application');
         });
     }
     if ($this->shouldCollect('memory', true)) {
         $this->addCollector(new MemoryCollector());
     }
     if ($this->shouldCollect('exceptions', true)) {
         $this->addCollector(new ExceptionsCollector());
     }
     if ($this->shouldCollect('laravel', false)) {
         $this->addCollector(new LaravelCollector());
     }
     if ($this->shouldCollect('default_request', false)) {
         $this->addCollector(new RequestDataCollector());
     }
     if ($this->shouldCollect('events', false) and isset($this->app['events'])) {
         $this->addCollector(new MessagesCollector('events'));
         $dispatcher = $this->app['events'];
         $dispatcher->listen('*', function () use($debugbar, $dispatcher) {
             if (method_exists($dispatcher, 'firing')) {
                 $event = $dispatcher->firing();
             } else {
                 $args = func_get_args();
                 $event = end($args);
             }
             $debugbar['events']->info("Received event: " . $event);
         });
     }
     if ($this->shouldCollect('views', true) and isset($this->app['events'])) {
         $collectData = $this->app['config']->get('laravel-debugbar::config.options.views.data', true);
         $this->addCollector(new ViewCollector($collectData));
         $this->app['events']->listen('composing:*', function ($view) use($debugbar) {
             $debugbar['views']->addView($view);
         });
     }
     if ($this->shouldCollect('route')) {
         if (version_compare($app::VERSION, '4.1', '>=')) {
             $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\IlluminateRouteCollector'));
         } else {
             $this->addCollector($this->app->make('Barryvdh\\Debugbar\\DataCollector\\SymfonyRouteCollector'));
         }
     }
     if ($this->shouldCollect('log', true)) {
         if ($this->hasCollector('messages')) {
             $logger = new MessagesCollector('log');
             $this['messages']->aggregate($logger);
             $this->app['log']->listen(function ($level, $message, $context) use($logger) {
                 if (is_array($message) or is_object($message)) {
                     $message = json_encode($message);
                 }
                 $log = '[' . date('H:i:s') . '] ' . "LOG.{$level}: " . $message . (!empty($context) ? ' ' . json_encode($context) : '');
                 $logger->addMessage($log, $level);
             });
         } else {
             $this->addCollector(new MonologCollector($this->app['log']->getMonolog()));
         }
     }
     if ($this->shouldCollect('db', true) and isset($this->app['db'])) {
         try {
             $pdo = new TraceablePDO($this->app['db']->getPdo());
             $pdoCollector = new PDOCollector($pdo);
             if ($this->app['config']->get('laravel-debugbar::config.options.pdo.with_params')) {
//.........这里部分代码省略.........
开发者ID:aaronbullard,项目名称:litmus,代码行数:101,代码来源:LaravelDebugBar.php


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