Bolt\Debug\ShutdownHandler::register PHP Méthode

register() public static méthode

Set the handlers.
public static register ( boolean $debug = true )
$debug boolean
    public static function register($debug = true)
    {
        $errorLevels = error_reporting();
        if ($debug) {
            $errorLevels |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
            Debug\DebugClassLoader::enable();
        }
        if (PHP_SAPI !== 'cli') {
            Debug\ErrorHandler::register()->throwAt($errorLevels, true);
            Debug\ExceptionHandler::register($debug);
        } else {
            $consoleHandler = function (\Exception $e) {
                $app = new Application('Bolt CLI', Version::VERSION);
                $output = new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG);
                $app->renderException($e, $output);
                ob_clean();
            };
            Debug\ExceptionHandler::register($debug)->setHandler($consoleHandler);
        }
    }

Usage Example

Exemple #1
0
 /**
  * @param array $values
  */
 public function __construct(array $values = [])
 {
     /** @internal Parameter to track a deprecated PHP version */
     $values['deprecated.php'] = version_compare(PHP_VERSION, '5.5.9', '<');
     // Register PHP shutdown functions to catch fatal errors & exceptions
     ShutdownHandler::register();
     parent::__construct($values);
     $this->register(new PathServiceProvider());
     // Initialize the config. Note that we do this here, on 'construct'.
     // All other initialisation is triggered from bootstrap.php
     // Warning!
     // One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
     // must be defined for working properly
     if (!isset($this['resources'])) {
         $this['resources'] = new Configuration\ResourceManager($this);
     } else {
         $this['classloader'] = $this['resources']->getClassLoader();
     }
     $this['resources']->setApp($this);
     $this->initConfig();
     $this->initLogger();
     $this['resources']->initialize();
     if (($debugOverride = $this['config']->get('general/debug')) !== null) {
         $this['debug'] = $debugOverride;
     }
     // Re-register the shutdown functions now that we know our debug setting
     ShutdownHandler::register($this['debug']);
     if (!isset($this['environment'])) {
         $this['environment'] = $this['debug'] ? 'development' : 'production';
     }
     if (($locales = $this['config']->get('general/locale')) !== null) {
         $locales = (array) $locales;
         $this['locale'] = reset($locales);
     }
     // Initialize the 'editlink' and 'edittitle'.
     $this['editlink'] = '';
     $this['edittitle'] = '';
     // Initialize the JavaScript data gateway.
     $this['jsdata'] = [];
 }
All Usage Examples Of Bolt\Debug\ShutdownHandler::register
ShutdownHandler