├── LICENSE ├── README.md ├── composer.json └── src ├── PhpConsole └── Laravel │ └── ServiceProvider.php └── config └── phpconsole.php /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Sergey Barbushin 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this 11 | list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Laravel 4.* service provider for PHP Console 2 | 3 | See https://github.com/barbushin/php-console-laravel/releases/tag/1.2.1 4 | 5 | Use `"php-console/laravel-service-provider": "1.*"` to install it using Compoer. 6 | 7 | ## Laravel 5.* service provider for PHP Console 8 | 9 | PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things using [Google Chrome extension PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) and [PhpConsole server library](https://github.com/barbushin/php-console). 10 | 11 | This packages integrates [PHP Console server library](https://github.com/barbushin/php-console) with [Laravel framework](http://laravel.com) as configurable service provider. 12 | 13 | ## Installation 14 | 15 | Require this package in Laravel project `composer.json` and run `composer update` 16 | 17 | "php-console/laravel-service-provider": "~5.0" 18 | 19 | After updating composer, add the service provider line at the begining of `providers` array in `/config/app.php` 20 | 21 | 'providers' => array( 22 | PhpConsole\Laravel\ServiceProvider::class, 23 | 24 | ## Edit config 25 | 26 | PHP Console service provider config-file looks like this: 27 | 28 | return array( 29 | 'isEnabled' => true, 30 | 'handleErrors' => true, 31 | 'handleExceptions' => true, 32 | 'sourcesBasePath' => base_path(), 33 | 'registerHelper' => true, 34 | 'serverEncoding' => null, 35 | 'headersLimit' => null, 36 | 'password' => null, 37 | 'enableSslOnlyMode' => false, 38 | 'ipMasks' => array(), 39 | 'isEvalEnabled' => false, 40 | 'dumperLevelLimit' => 5, 41 | 'dumperItemsCountLimit' => 100, 42 | 'dumperItemSizeLimit' => 5000, 43 | 'dumperDumpSizeLimit' => 500000, 44 | 'dumperDetectCallbacks' => true, 45 | 'detectDumpTraceAndSource' => false, 46 | ); 47 | 48 | See [PhpConsole\Laravel\ServiceProvider](/src/PhpConsole/Laravel/ServiceProvider.php) for detailed options description. 49 | 50 | By default it's located in `/vendor/php-console/laravel-service-provider/src/config/phpconsole.php` and it's not recommended to be edited in this path because it will be overwritten on next `composer update`. 51 | 52 | If you want to edit config you need to run 53 | 54 | $ php artisan vendor:publish --provider="php-console/laravel-service-provider" --tag=config 55 | $ php artisan vendor:publish 56 | 57 | So config-file will be moved to `/config/phpconsole.php` and can be edited as you want and changes will not be lost after `composer update`. 58 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "php-console/laravel-service-provider", 3 | "description": "Laravel service provider to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome", 4 | "keywords": [ 5 | "Laravel", 6 | "PHP", 7 | "errors", 8 | "debug", 9 | "chrome", 10 | "error handler", 11 | "google chrome", 12 | "php-console" 13 | ], 14 | "homepage": "https://github.com/barbushin/php-console-laravel", 15 | "license": "BSD 3-Clause", 16 | "type": "library", 17 | "authors": [ 18 | { 19 | "name": "Barbushin Sergey", 20 | "email": "barbushin@gmail.com", 21 | "homepage": "http://linkedin.com/in/barbushin" 22 | }, 23 | { 24 | "name": "Wemerson Januario", 25 | "email": "wemerson.januario@gmail.com", 26 | "homepage": "http://linkedin.com/in/wemersonjanuario", 27 | "role": "Laravel 5 support" 28 | } 29 | ], 30 | "support": { 31 | "issues": "https://github.com/barbushin/php-console-laravel/issues?state=open" 32 | }, 33 | "require": { 34 | "php": ">=5.3.0", 35 | "illuminate/support": "5.*", 36 | "php-console/php-console": ">=3.1.4 <4.0" 37 | }, 38 | "autoload": { 39 | "psr-0": { 40 | "PhpConsole\\Laravel\\": "src/" 41 | } 42 | }, 43 | "minimum-stability": "dev", 44 | "extra": { 45 | "branch-alias": { 46 | "dev-master": "5.x-dev" 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PhpConsole/Laravel/ServiceProvider.php: -------------------------------------------------------------------------------- 1 | password is required to be set 55 | * use $this->ipMasks & $this->enableSslOnlyMode for additional protection 56 | */ 57 | protected $isEvalEnabled = false; 58 | 59 | /** 60 | * Indicates if loading of the provider is deferred. 61 | * 62 | * @var bool 63 | */ 64 | protected $defer = false; 65 | 66 | /** 67 | * Register the service provider. 68 | * 69 | * @return void 70 | */ 71 | public function register() { 72 | $this->mergeConfigFrom(__DIR__ . '/../../config/phpconsole.php', 'phpconsole'); 73 | } 74 | 75 | /** 76 | * Bootstrap the application events. 77 | * 78 | * @return void 79 | */ 80 | public function boot() { 81 | $this->publishes([__DIR__ . '/../../config/phpconsole.php' => config_path('phpconsole.php')], 'config'); 82 | 83 | foreach (config('phpconsole') as $option => $value) { 84 | $this->setOption($option, $value); 85 | } 86 | $this->initPhpConsole(); 87 | } 88 | 89 | protected function setOption($name, $value) { 90 | if (!property_exists($this, $name)) { 91 | throw new \Exception('Unknown property "' . $name . '" in ' . static::PACKAGE_ALIAS . ' package config'); 92 | } 93 | $this->$name = $value; 94 | } 95 | 96 | protected function initPhpConsole() { 97 | if (!$this->dataStorage) { 98 | $this->dataStorage = new PhpConsole\Storage\File(storage_path('php-console.dat'), true); 99 | } 100 | if ($this->dataStorage instanceof \PhpConsole\Storage\Session) { 101 | throw new \Exception('Unable to use PhpConsole\Storage\Session as PhpConsole storage interface because of problems with overridden $_SESSION handler in Laravel'); 102 | } 103 | Connector::setPostponeStorage($this->dataStorage); 104 | 105 | $connector = Connector::getInstance(); 106 | 107 | if ($this->registerHelper) { 108 | Helper::register(); 109 | } 110 | 111 | $isActiveClient = $connector->isActiveClient(); 112 | if (!$this->isEnabled || !$isActiveClient) { 113 | if($isActiveClient) { 114 | $connector->disable(); 115 | } 116 | return; 117 | } 118 | 119 | $handler = Handler::getInstance(); 120 | $handler->setHandleErrors($this->handleErrors); 121 | $handler->setHandleErrors($this->handleExceptions); 122 | $handler->start(); 123 | 124 | if ($this->sourcesBasePath) { 125 | $connector->setSourcesBasePath($this->sourcesBasePath); 126 | } 127 | if ($this->serverEncoding) { 128 | $connector->setServerEncoding($this->serverEncoding); 129 | } 130 | if ($this->password) { 131 | $connector->setPassword($this->password); 132 | } 133 | if ($this->enableSslOnlyMode) { 134 | $connector->enableSslOnlyMode(); 135 | } 136 | if ($this->ipMasks) { 137 | $connector->setAllowedIpMasks($this->ipMasks); 138 | } 139 | if ($this->headersLimit) { 140 | $connector->setHeadersLimit($this->headersLimit); 141 | } 142 | 143 | if ($this->detectDumpTraceAndSource) { 144 | $connector->getDebugDispatcher()->detectTraceAndSource = true; 145 | } 146 | 147 | $dumper = $connector->getDumper(); 148 | $dumper->levelLimit = $this->dumperLevelLimit; 149 | $dumper->itemsCountLimit = $this->dumperItemsCountLimit; 150 | $dumper->itemSizeLimit = $this->dumperItemSizeLimit; 151 | $dumper->dumpSizeLimit = $this->dumperDumpSizeLimit; 152 | $dumper->detectCallbacks = $this->dumperDetectCallbacks; 153 | 154 | if ($this->isEvalEnabled) { 155 | $connector->startEvalRequestsListener(); 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/config/phpconsole.php: -------------------------------------------------------------------------------- 1 | true, 7 | 'handleErrors' => true, 8 | 'handleExceptions' => true, 9 | 'sourcesBasePath' => base_path(), 10 | 'registerHelper' => true, 11 | 'serverEncoding' => null, 12 | 'headersLimit' => null, 13 | 'password' => null, 14 | 'enableSslOnlyMode' => false, 15 | 'ipMasks' => array(), 16 | 'isEvalEnabled' => false, 17 | 'dumperLevelLimit' => 5, 18 | 'dumperItemsCountLimit' => 100, 19 | 'dumperItemSizeLimit' => 5000, 20 | 'dumperDumpSizeLimit' => 500000, 21 | 'dumperDetectCallbacks' => true, 22 | 'detectDumpTraceAndSource' => false, 23 | 'dataStorage' => new PhpConsole\Storage\File(storage_path('php-console.dat'), true), 24 | ); 25 | --------------------------------------------------------------------------------