/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('darsain/laravel-console'); $src_path = __DIR__ . '/../../'; // Routes require $src_path . 'routes.php'; // Attach Console events Console::attach(); }
public function postExecute() { $code = Input::get('code'); // Execute and profile the code $profile = Console::execute($code); // Terminate on error, as Error Handler already responded. if (isset($profile['error']) and $profile['error']) { exit; } // Response return Response::json($profile); }
/** * Register the service provider. * * @return void */ public function register() { if ($this->app['request']->is('console') and $this->app['request']->getMethod() == 'POST') { $this->app->singleton('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'Darsain\\Console\\Handler'); } $configPath = __DIR__ . '/../../config/config.php'; $routePath = __DIR__ . '/../../routes.php'; $viewPath = __DIR__ . '/../../views'; $this->mergeConfigFrom($configPath, 'console'); $this->loadViewsFrom($viewPath, 'console'); // Routes require $routePath; // Attach Console events Console::attach(); }
/** * Attaches Laravel event listeners. */ public static function attach() { Event::listen('illuminate.query', function ($sql, $bindings, $time) { Console::query($sql, $bindings, $time); }); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { Console::addProfile('error', array('type' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine())); return Response::json(Console::getProfile(), 200); }