From 0bb6bdf4409f624103454609c19ce06206601527 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Fri, 6 Feb 2015 13:57:14 +0700 Subject: [PATCH 01/18] support Laravel 5.x --- public/js/main.js | 5 +- .../Console/ConsoleServiceProvider.php | 105 ++++++++++-------- src/Darsain/Console/Handler.php | 30 +++++ src/controllers/ConsoleController.php | 6 +- src/routes.php | 14 ++- src/views/console.blade.php | 2 + src/views/partials/foot.blade.php | 8 +- src/views/partials/head.blade.php | 10 +- 8 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 src/Darsain/Console/Handler.php diff --git a/public/js/main.js b/public/js/main.js index d158ce6..e5211f1 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -56,6 +56,8 @@ jQuery(function ($) { var $response = $('#response'); var $controlbar = $('#controlbar'); var $editor = $('#editor'); + + var action = $console.data('action'); var $execute = $('#execute'); var $controls = $('#controls'); @@ -107,7 +109,8 @@ jQuery(function ($) { type: 'POST', cache: false, data: { - code: editor.getValue() + code: editor.getValue(), + '_token': $('#token').val() }, dataType: 'text', timeout: 30000 diff --git a/src/Darsain/Console/ConsoleServiceProvider.php b/src/Darsain/Console/ConsoleServiceProvider.php index 1f4b44d..262a9c8 100644 --- a/src/Darsain/Console/ConsoleServiceProvider.php +++ b/src/Darsain/Console/ConsoleServiceProvider.php @@ -4,49 +4,66 @@ class ConsoleServiceProvider extends ServiceProvider { - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - - /** - * 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(); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array(); - } + /** + * Indicates if loading of the provider is deferred. + * + * @var bool + */ + protected $defer = false; + + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + if ($this->app['request']->is('console') and $this->app['request']->getMethod() == 'POST') + { + $this->app->singleton( + 'Illuminate\Contracts\Debug\ExceptionHandler', + 'Darsain\Console\Handler' + ); + } + + $this->publishes([ + __DIR__.'/../../config/config.php' => config_path('laravel-console.php'), + __DIR__.'/../../../public/' => base_path('public/packages/darsain/laravel-console'), + ]); + + $this->mergeConfigFrom( + __DIR__.'/../../config/config.php', 'laravel-console' + ); + + $this->loadViewsFrom(__DIR__.'/../../views', 'laravel-console'); + + $src_path = __DIR__ . '/../../'; + + // Routes + require $src_path . 'routes.php'; + + // Attach Console events + Console::attach(); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } } \ No newline at end of file diff --git a/src/Darsain/Console/Handler.php b/src/Darsain/Console/Handler.php new file mode 100644 index 0000000..942a4c2 --- /dev/null +++ b/src/Darsain/Console/Handler.php @@ -0,0 +1,30 @@ + $e->getCode(), + 'message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + )); + + return Response::json(Console::getProfile(), 200); + } + +} diff --git a/src/controllers/ConsoleController.php b/src/controllers/ConsoleController.php index 8a50cb8..c5c318f 100644 --- a/src/controllers/ConsoleController.php +++ b/src/controllers/ConsoleController.php @@ -1,8 +1,10 @@ Config::get('laravel-console::filter')), function () { +Route::group(array('before' => Config::get('laravel-console.filter')), function () { Route::get('console', 'Darsain\Console\ConsoleController@getIndex'); + Route::post('console', array( - 'as' => 'console_execute', - 'uses' => 'Darsain\Console\ConsoleController@postExecute' + 'middleware' => [], + 'as' => 'console_execute', + 'uses' => 'Darsain\Console\ConsoleController@postExecute' )); }); @@ -46,7 +52,7 @@ Route::filter('console_whitelist', function () { - if (!in_array($_SERVER['REMOTE_ADDR'], Config::get('laravel-console::whitelist'), true)) + if (!in_array($_SERVER['REMOTE_ADDR'], Config::get('laravel-console.whitelist'), true)) { App::abort(404); } diff --git a/src/views/console.blade.php b/src/views/console.blade.php index 3160ebd..386a57e 100644 --- a/src/views/console.blade.php +++ b/src/views/console.blade.php @@ -13,6 +13,8 @@
+ + @include('laravel-console::partials.templates') diff --git a/src/views/partials/foot.blade.php b/src/views/partials/foot.blade.php index 7c16c80..af0773e 100644 --- a/src/views/partials/foot.blade.php +++ b/src/views/partials/foot.blade.php @@ -1,6 +1,6 @@ - {{ HTML::script('packages/darsain/laravel-console/js/vendor/jquery.js') }} - {{ HTML::script('packages/darsain/laravel-console/js/vendor/plugins.js') }} - {{ HTML::script('packages/darsain/laravel-console/js/vendor/codemirror.js') }} - {{ HTML::script('packages/darsain/laravel-console/js/main.js') }} + + + + \ No newline at end of file diff --git a/src/views/partials/head.blade.php b/src/views/partials/head.blade.php index 5bf0996..d1b001b 100644 --- a/src/views/partials/head.blade.php +++ b/src/views/partials/head.blade.php @@ -6,11 +6,11 @@ Laravel Console - {{ HTML::style('packages/darsain/laravel-console/css/normalize.css') }} - {{ HTML::style('packages/darsain/laravel-console/css/main.css') }} - {{ HTML::style('packages/darsain/laravel-console/css/codemirror.css') }} - {{ HTML::style('packages/darsain/laravel-console/css/laravel.css') }} + + + + - {{ HTML::script('packages/darsain/laravel-console/js/vendor/modernizr.js') }} + \ No newline at end of file From 6f58ef225d74a61c8ba846ed4656ebd21b3dc9df Mon Sep 17 00:00:00 2001 From: Teepluss Date: Mon, 9 Feb 2015 15:38:59 +0700 Subject: [PATCH 02/18] change description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 718e6b7..a2ed757 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Laravel 4 Console +# Laravel 5 Console In-browser console for Laravel 4 PHP framework. From 4be0b5469fdf145549f2a9da5170ca146a2bb080 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Tue, 10 Feb 2015 05:33:48 +0000 Subject: [PATCH 03/18] update readme --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a2ed757..30be398 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel 5 Console -In-browser console for Laravel 4 PHP framework. +In-browser console for Laravel 5 PHP framework. This bundle executes your code within `ConsoleController@postExecute` context, and displays the produced output. @@ -17,14 +17,14 @@ This bundle is intended for a local testing, and **shouldn't get nowhere near yo ## Installation -### Laravel 4 +### Laravel 5 Add this into `require-dev` in your `composer.json` file: ``` "require-dev" : { ... - "darsain/laravel-console": "dev-master" + "darsain/laravel-console": "dev-L5" } ``` @@ -34,19 +34,19 @@ Run an update: php composer.phar update ``` -Register the console service provider in `app/config/app.php`: +Register the console service provider in `config/app.php`: ```php -'providers' => array( +'providers' => [ ... 'Darsain\Console\ConsoleServiceProvider', -); +]; ``` Then publish the bundle assets: ``` -php artisan asset:publish +php artisan vendor:publish ``` And you are done! Open the console in: @@ -54,7 +54,3 @@ And you are done! Open the console in: ``` yourdomain.com/console ``` - -### Laravel 3 - -Laravel 3 version along with installation process can be found in the [L3 branch](https://github.com/Darsain/laravel-console/tree/L3). From 3fbe544c5fcae7153a7c86d2ec115a076ec60188 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 11 Feb 2015 10:41:30 +0700 Subject: [PATCH 04/18] remove prefix laravel --- .../Console/ConsoleServiceProvider.php | 8 +++--- src/config/config.php | 2 +- src/controllers/ConsoleController.php | 2 +- src/routes.php | 28 ++----------------- src/views/console.blade.php | 6 ++-- src/views/partials/foot.blade.php | 8 +++--- src/views/partials/head.blade.php | 10 +++---- 7 files changed, 20 insertions(+), 44 deletions(-) diff --git a/src/Darsain/Console/ConsoleServiceProvider.php b/src/Darsain/Console/ConsoleServiceProvider.php index 262a9c8..7ee538d 100644 --- a/src/Darsain/Console/ConsoleServiceProvider.php +++ b/src/Darsain/Console/ConsoleServiceProvider.php @@ -27,15 +27,15 @@ public function boot() } $this->publishes([ - __DIR__.'/../../config/config.php' => config_path('laravel-console.php'), - __DIR__.'/../../../public/' => base_path('public/packages/darsain/laravel-console'), + __DIR__.'/../../config/config.php' => config_path('console.php'), + __DIR__.'/../../../public/' => base_path('public/packages/darsain/console'), ]); $this->mergeConfigFrom( - __DIR__.'/../../config/config.php', 'laravel-console' + __DIR__.'/../../config/config.php', 'console' ); - $this->loadViewsFrom(__DIR__.'/../../views', 'laravel-console'); + $this->loadViewsFrom(__DIR__.'/../../views', 'console'); $src_path = __DIR__ . '/../../'; diff --git a/src/config/config.php b/src/config/config.php index 3660a93..abfd402 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -26,6 +26,6 @@ | */ - 'whitelist' => array('127.0.0.1', '::1'), + 'whitelist' => array('127.0.0.1', '192.168.10.1', '::1'), ); diff --git a/src/controllers/ConsoleController.php b/src/controllers/ConsoleController.php index c5c318f..8773010 100644 --- a/src/controllers/ConsoleController.php +++ b/src/controllers/ConsoleController.php @@ -8,7 +8,7 @@ class ConsoleController extends BaseController { public function getIndex() { - return View::make('laravel-console::console'); + return View::make('console::console'); } public function postExecute() diff --git a/src/routes.php b/src/routes.php index 811d03a..2f8d580 100644 --- a/src/routes.php +++ b/src/routes.php @@ -2,37 +2,13 @@ use Darsain\Console\Console; -/* -|-------------------------------------------------------------------------- -| Error handler -|-------------------------------------------------------------------------- -*/ - -/* -App::error(function (Exception $e, $code) { - if (App::runningInConsole() or !(Request::url() === 'console' and $_SERVER['REQUEST_METHOD'] === 'POST')) { - return; - } - @ob_end_clean(); - Console::addProfile('error', array( - 'type' => $code, - 'message' => $e->getMessage(), - 'file' => $e->getFile(), - 'line' => $e->getLine(), - )); - return Response::json(Console::getProfile(), 200); -}); -*/ - - - /* |-------------------------------------------------------------------------- | Routes |-------------------------------------------------------------------------- */ -Route::group(array('before' => Config::get('laravel-console.filter')), function () { +Route::group(array('before' => Config::get('console.filter')), function () { Route::get('console', 'Darsain\Console\ConsoleController@getIndex'); @@ -52,7 +28,7 @@ Route::filter('console_whitelist', function () { - if (!in_array($_SERVER['REMOTE_ADDR'], Config::get('laravel-console.whitelist'), true)) + if (!in_array($_SERVER['REMOTE_ADDR'], Config::get('console.whitelist'), true)) { App::abort(404); } diff --git a/src/views/console.blade.php b/src/views/console.blade.php index 386a57e..14152a5 100644 --- a/src/views/console.blade.php +++ b/src/views/console.blade.php @@ -1,4 +1,4 @@ -@include('laravel-console::partials.head') +@include('console::partials.head')
    @@ -17,5 +17,5 @@
-@include('laravel-console::partials.templates') -@include('laravel-console::partials.foot') \ No newline at end of file +@include('console::partials.templates') +@include('console::partials.foot') \ No newline at end of file diff --git a/src/views/partials/foot.blade.php b/src/views/partials/foot.blade.php index af0773e..5c921ad 100644 --- a/src/views/partials/foot.blade.php +++ b/src/views/partials/foot.blade.php @@ -1,6 +1,6 @@ - - - - + + + + \ No newline at end of file diff --git a/src/views/partials/head.blade.php b/src/views/partials/head.blade.php index d1b001b..78eae5d 100644 --- a/src/views/partials/head.blade.php +++ b/src/views/partials/head.blade.php @@ -6,11 +6,11 @@ Laravel Console - - - - + + + + - + \ No newline at end of file From 0a41cad844f02b33dd3613ae10bd76bb7594d361 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 18 Feb 2015 13:06:01 +0700 Subject: [PATCH 05/18] move everything in boot to register --- src/Darsain/Console/ConsoleServiceProvider.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Darsain/Console/ConsoleServiceProvider.php b/src/Darsain/Console/ConsoleServiceProvider.php index 7ee538d..b0eae27 100644 --- a/src/Darsain/Console/ConsoleServiceProvider.php +++ b/src/Darsain/Console/ConsoleServiceProvider.php @@ -12,11 +12,11 @@ class ConsoleServiceProvider extends ServiceProvider { protected $defer = false; /** - * Bootstrap the application events. + * Register the service provider. * * @return void */ - public function boot() + public function register() { if ($this->app['request']->is('console') and $this->app['request']->getMethod() == 'POST') { @@ -46,16 +46,6 @@ public function boot() Console::attach(); } - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // - } - /** * Get the services provided by the provider. * From 7ceb496d0b4a0828eab7e4cce90474b4643fa568 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Mon, 2 Mar 2015 12:14:02 +0700 Subject: [PATCH 06/18] add boot to service provider --- .../Console/ConsoleServiceProvider.php | 33 +++++++++++++------ src/views/console.blade.php | 3 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Darsain/Console/ConsoleServiceProvider.php b/src/Darsain/Console/ConsoleServiceProvider.php index b0eae27..ef268aa 100644 --- a/src/Darsain/Console/ConsoleServiceProvider.php +++ b/src/Darsain/Console/ConsoleServiceProvider.php @@ -11,6 +11,23 @@ class ConsoleServiceProvider extends ServiceProvider { */ protected $defer = false; + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + $configPath = __DIR__.'/../../config/config.php'; + $publicPath = __DIR__.'/../../../public'; + + // Publish config. + $this->publishes([ + $configPath => config_path('console.php'), + $publicPath => base_path('public/packages/darsain/console'), + ]); + } + /** * Register the service provider. * @@ -26,21 +43,17 @@ public function register() ); } - $this->publishes([ - __DIR__.'/../../config/config.php' => config_path('console.php'), - __DIR__.'/../../../public/' => base_path('public/packages/darsain/console'), - ]); + $configPath = __DIR__.'/../../config/config.php'; + $routePath = __DIR__ . '/../../routes.php'; + $viewPath = __DIR__.'/../../views'; - $this->mergeConfigFrom( - __DIR__.'/../../config/config.php', 'console' - ); - $this->loadViewsFrom(__DIR__.'/../../views', 'console'); + $this->mergeConfigFrom($configPath, 'console'); - $src_path = __DIR__ . '/../../'; + $this->loadViewsFrom($viewPath, 'console'); // Routes - require $src_path . 'routes.php'; + require $routePath; // Attach Console events Console::attach(); diff --git a/src/views/console.blade.php b/src/views/console.blade.php index 14152a5..7991c08 100644 --- a/src/views/console.blade.php +++ b/src/views/console.blade.php @@ -11,8 +11,7 @@
Execute
-
-
+
From de8a3c35b212bb061acd677d5257d934d0a5b9a1 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Fri, 24 Apr 2015 05:42:28 +0000 Subject: [PATCH 07/18] middleware config added --- README.md | 2 +- src/config/config.php | 16 +--------------- src/routes.php | 26 ++++++++++---------------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 30be398..5750466 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Register the console service provider in `config/app.php`: Then publish the bundle assets: ``` -php artisan vendor:publish +php artisan vendor:publish --provider="Darsain\Console\ConsoleServiceProvider" ``` And you are done! Open the console in: diff --git a/src/config/config.php b/src/config/config.php index abfd402..20fc330 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,20 +12,6 @@ | */ - 'filter' => 'console_whitelist', - - /* - |-------------------------------------------------------------------------- - | Enable console only for this locations - |-------------------------------------------------------------------------- - | - | Addresses allowed to access the console. This array is used in - | 'console_whitelist' route filter. Nevertheless, this bundle should never - | get nowhere near your production servers, but who am I to tell you how - | to live your life :) - | - */ - - 'whitelist' => array('127.0.0.1', '192.168.10.1', '::1'), + 'middleware' => null, ); diff --git a/src/routes.php b/src/routes.php index 2f8d580..c6aab51 100644 --- a/src/routes.php +++ b/src/routes.php @@ -8,7 +8,16 @@ |-------------------------------------------------------------------------- */ -Route::group(array('before' => Config::get('console.filter')), function () { +$group = []; + +$middleware = Config::get('console.middleware'); + +if ( ! is_null($middleware)) +{ + $group['middleware'] = $middleware; +} + +Route::group($group, function () { Route::get('console', 'Darsain\Console\ConsoleController@getIndex'); @@ -19,18 +28,3 @@ )); }); - -/* -|-------------------------------------------------------------------------- -| Route Filters -|-------------------------------------------------------------------------- -*/ - -Route::filter('console_whitelist', function () { - - if (!in_array($_SERVER['REMOTE_ADDR'], Config::get('console.whitelist'), true)) - { - App::abort(404); - } - -}); From 2aadafe86be09727a0ea6b4bf1a5c46afab86b0b Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 10 Jun 2015 14:11:08 +0700 Subject: [PATCH 08/18] update support 5.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f0f9ab4..b47ed72 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "license": "MIT", "require": { "php": ">=5.3.0", - "illuminate/support": ">=4.0.0" + "illuminate/support": ">=5.0.*" }, "autoload": { "classmap": [ From b909bef16f1bddf37d98cc17b7dcf9780ecb3d58 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 10 Jun 2015 14:14:23 +0700 Subject: [PATCH 09/18] update support 5.1 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b47ed72..9579656 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ ], "license": "MIT", "require": { - "php": ">=5.3.0", - "illuminate/support": ">=5.0.*" + "php": ">=5.4.0", + "illuminate/support": ">=5.0.1" }, "autoload": { "classmap": [ From faded23810d47c6b0e8257d20251ae08c2c0c101 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Mon, 7 Sep 2015 11:08:42 +0700 Subject: [PATCH 10/18] update readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5750466..ccd84f3 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,15 @@ This bundle is intended for a local testing, and **shouldn't get nowhere near yo ### Laravel 5 -Add this into `require-dev` in your `composer.json` file: +Add this into `repositories` and `require-dev` in your `composer.json` file: ``` +"repositories": [ + { + "type": "vcs", + "url": "https://github.com/teepluss/laravel-console" + } +], "require-dev" : { ... "darsain/laravel-console": "dev-L5" From ec75db8ce00921c6f74f43f260e059eda501e72a Mon Sep 17 00:00:00 2001 From: Teepluss Date: Mon, 7 Sep 2015 11:09:27 +0700 Subject: [PATCH 11/18] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccd84f3..cf38d34 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This bundle is intended for a local testing, and **shouldn't get nowhere near yo Add this into `repositories` and `require-dev` in your `composer.json` file: -``` +```json "repositories": [ { "type": "vcs", From 8df5717ede4dd6cdc8ff09b7d8ec04f968d1ebb9 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Mon, 7 Sep 2015 11:09:46 +0700 Subject: [PATCH 12/18] update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index cf38d34..5317434 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ Add this into `repositories` and `require-dev` in your `composer.json` file: } ], "require-dev" : { - ... "darsain/laravel-console": "dev-L5" } ``` From f4e1ee829985a416313d27abd0b332858919d033 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Tue, 12 Jan 2016 09:32:57 +0000 Subject: [PATCH 13/18] fix facade called --- src/controllers/ConsoleController.php | 17 ++++++++++------- src/routes.php | 10 +++------- src/views/console.blade.php | 6 ++---- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/controllers/ConsoleController.php b/src/controllers/ConsoleController.php index 8773010..bad24ae 100644 --- a/src/controllers/ConsoleController.php +++ b/src/controllers/ConsoleController.php @@ -1,11 +1,15 @@ - [], 'as' => 'console_execute', 'uses' => 'Darsain\Console\ConsoleController@postExecute' - )); - + ]); }); diff --git a/src/views/console.blade.php b/src/views/console.blade.php index 7991c08..704013f 100644 --- a/src/views/console.blade.php +++ b/src/views/console.blade.php @@ -7,14 +7,12 @@
- - + @include('console::partials.templates') -@include('console::partials.foot') \ No newline at end of file +@include('console::partials.foot') From b02daa54949f476ade2834aa2a73859cc9c3b5f6 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Thu, 18 Aug 2016 09:48:47 +0200 Subject: [PATCH 14/18] Fix SQL query logs with Laravel 5.2 Source: https://github.com/barryvdh/laravel-debugbar/blob/v2.2.2/src/LaravelDebugbar.php#L297 --- src/Darsain/Console/Console.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Darsain/Console/Console.php b/src/Darsain/Console/Console.php index 8b33377..2a70d4e 100644 --- a/src/Darsain/Console/Console.php +++ b/src/Darsain/Console/Console.php @@ -169,10 +169,23 @@ public static function query($sql, $bindings, $time) */ public static function attach() { - Event::listen('illuminate.query', function ($sql, $bindings, $time) - { - Console::query($sql, $bindings, $time); - }); + $db = app('db'); + $db->listen( + function ($query, $bindings = null, $time = null, $connectionName = null) use ($db) { + // Laravel 5.2 changed the way some core events worked. We must account for + // the first argument being an "event object", where arguments are passed + // via object properties, instead of individual arguments. + if ($query instanceof \Illuminate\Database\Events\QueryExecuted) { + $bindings = $query->bindings; + $time = $query->time; + $connection = $query->connection; + $query = $query->sql; + } else { + $connection = $db->connection($connectionName); + } + Console::query((string) $query, $bindings, $time); + } + ); } /** From 6c2822a431015081966fdca51d681ba6646f7008 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 26 Oct 2016 22:58:08 +0700 Subject: [PATCH 15/18] update reademe --- README.md | 2 +- src/config/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5317434..fcc16cc 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Register the console service provider in `config/app.php`: ```php 'providers' => [ ... - 'Darsain\Console\ConsoleServiceProvider', + Darsain\Console\ConsoleServiceProvider::class, ]; ``` diff --git a/src/config/config.php b/src/config/config.php index 20fc330..a85205c 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,6 +12,6 @@ | */ - 'middleware' => null, + 'middleware' => ['web'], ); From eb0f20da154ece1fc0a8035b9a9847d848cd5944 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 26 Oct 2016 23:01:53 +0700 Subject: [PATCH 16/18] update reademe --- src/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/config.php b/src/config/config.php index a85205c..b7871a7 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,6 +12,6 @@ | */ - 'middleware' => ['web'], + 'middleware' => [], ); From 0858f265b652b6ea79f500a409504a7b8d269634 Mon Sep 17 00:00:00 2001 From: Teepluss Date: Wed, 2 Nov 2016 23:36:34 +0700 Subject: [PATCH 17/18] re-published package --- README.md | 26 ++++---------- composer.json | 17 ++++++--- public/js/main.js | 4 +-- .../Console/ConsoleServiceProvider.php | 36 +++++++++---------- src/config/config.php | 2 +- src/views/console.blade.php | 3 +- src/views/partials/foot.blade.php | 10 +++--- src/views/partials/head.blade.php | 17 +++++---- 8 files changed, 58 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index fcc16cc..ba7e5ef 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,14 @@ In-browser console for Laravel 5 PHP framework. -This bundle executes your code within `ConsoleController@postExecute` context, and displays the produced output. +This package is a re-published, re-organised and maintained version of darsain/laravel-console, which isn't maintained anymore. + +This package executes your code within `ConsoleController@postExecute` context, and displays the produced output. The purpose is to easily test your stuff without creating garbage routes and controllers just to run something, ... I'm sure you know what I'm talking about :) -This bundle is intended for a local testing, and **shouldn't get nowhere near your production servers!** +This package is intended for a local testing, and **shouldn't get nowhere near your production servers!** ## Screenshots @@ -19,24 +21,10 @@ This bundle is intended for a local testing, and **shouldn't get nowhere near yo ### Laravel 5 -Add this into `repositories` and `require-dev` in your `composer.json` file: - -```json -"repositories": [ - { - "type": "vcs", - "url": "https://github.com/teepluss/laravel-console" - } -], -"require-dev" : { - "darsain/laravel-console": "dev-L5" -} -``` - -Run an update: +To install through composer, simply run the following command: ``` -php composer.phar update +php cocomposer require teepluss/laravel-console ``` Register the console service provider in `config/app.php`: @@ -48,7 +36,7 @@ Register the console service provider in `config/app.php`: ]; ``` -Then publish the bundle assets: +Then publish the package assets: ``` php artisan vendor:publish --provider="Darsain\Console\ConsoleServiceProvider" diff --git a/composer.json b/composer.json index 9579656..1bc9dde 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "darsain/laravel-console", + "name": "teepluss/laravel-console", "description": "Browser console for Laravel Framework.", "keywords": [ "laravel", @@ -7,9 +7,17 @@ "console" ], "license": "MIT", + "authors": [ + { + "name": "Teepluss", + "email": "teepluss@gmail.com", + "homepage": "https://github.com/teepluss", + "role": "Developer" + } + ], "require": { "php": ">=5.4.0", - "illuminate/support": ">=5.0.1" + "illuminate/support": ">=5.1.0" }, "autoload": { "classmap": [ @@ -19,5 +27,6 @@ "Darsain\\Console\\": "src/" } }, - "minimum-stability": "dev" -} \ No newline at end of file + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/public/js/main.js b/public/js/main.js index e5211f1..e0df771 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -108,9 +108,9 @@ jQuery(function ($) { var execution = $.ajax(action, { type: 'POST', cache: false, + headers: { 'X-CSRF-TOKEN': Laravel.csrfToken }, data: { - code: editor.getValue(), - '_token': $('#token').val() + code: editor.getValue() }, dataType: 'text', timeout: 30000 diff --git a/src/Darsain/Console/ConsoleServiceProvider.php b/src/Darsain/Console/ConsoleServiceProvider.php index ef268aa..861a261 100644 --- a/src/Darsain/Console/ConsoleServiceProvider.php +++ b/src/Darsain/Console/ConsoleServiceProvider.php @@ -18,14 +18,11 @@ class ConsoleServiceProvider extends ServiceProvider { */ public function boot() { - $configPath = __DIR__.'/../../config/config.php'; - $publicPath = __DIR__.'/../../../public'; - // Publish config. $this->publishes([ - $configPath => config_path('console.php'), - $publicPath => base_path('public/packages/darsain/console'), - ]); + __DIR__.'/../../config/config.php' => config_path('console.php'), + __DIR__.'/../../../public' => base_path('public/vendor/darsain/console'), + ], 'public'); } /** @@ -35,25 +32,28 @@ public function boot() */ public function register() { - if ($this->app['request']->is('console') and $this->app['request']->getMethod() == 'POST') - { - $this->app->singleton( + if ($this->app['request']->is('console') and $this->app['request']->getMethod() == 'POST') { + $this->app->bind( 'Illuminate\Contracts\Debug\ExceptionHandler', 'Darsain\Console\Handler' ); } - $configPath = __DIR__.'/../../config/config.php'; - $routePath = __DIR__ . '/../../routes.php'; - $viewPath = __DIR__.'/../../views'; - + $this->mergeConfigFrom( + __DIR__.'/../../config/config.php', 'console' + ); - $this->mergeConfigFrom($configPath, 'console'); + $this->loadViewsFrom( + __DIR__.'/../../views', 'console' + ); - $this->loadViewsFrom($viewPath, 'console'); + $this->publishes([ + __DIR__.'/../../views' => resource_path('views/vendor/console'), + ], 'view'); - // Routes - require $routePath; + if (! $this->app->routesAreCached()) { + require __DIR__ . '/../../routes.php'; + } // Attach Console events Console::attach(); @@ -69,4 +69,4 @@ public function provides() return array(); } -} \ No newline at end of file +} diff --git a/src/config/config.php b/src/config/config.php index b7871a7..a85205c 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -12,6 +12,6 @@ | */ - 'middleware' => [], + 'middleware' => ['web'], ); diff --git a/src/views/console.blade.php b/src/views/console.blade.php index 704013f..9286340 100644 --- a/src/views/console.blade.php +++ b/src/views/console.blade.php @@ -1,6 +1,6 @@ @include('console::partials.head') -
+
@@ -11,7 +11,6 @@
-
@include('console::partials.templates') diff --git a/src/views/partials/foot.blade.php b/src/views/partials/foot.blade.php index 5c921ad..d597f45 100644 --- a/src/views/partials/foot.blade.php +++ b/src/views/partials/foot.blade.php @@ -1,6 +1,6 @@ - - - - + + + + - \ No newline at end of file + diff --git a/src/views/partials/head.blade.php b/src/views/partials/head.blade.php index 78eae5d..8a1f83a 100644 --- a/src/views/partials/head.blade.php +++ b/src/views/partials/head.blade.php @@ -6,11 +6,16 @@ Laravel Console - - - - + + + + - + + - \ No newline at end of file + From 8b8c04eff323a6777258ac86825e5f25d91bc0db Mon Sep 17 00:00:00 2001 From: Pattanai Date: Wed, 4 Jan 2017 16:03:29 +0700 Subject: [PATCH 18/18] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1bc9dde..eeb45f9 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "teepluss/laravel-console", + "name": "darsain/laravel-console", "description": "Browser console for Laravel Framework.", "keywords": [ "laravel",