Skip to content

Commit

Permalink
Start of Laravel 5 changes
Browse files Browse the repository at this point in the history
Remove some checks, change configuration, remove old middleware.
  • Loading branch information
barryvdh committed Jan 10, 2015
1 parent 99e6f44 commit d4bc7b1
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 140 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
"description": "PHP Debugbar integration for Laravel",
"keywords": ["laravel", "debugbar", "profiler", "debug", "webprofiler"],
"license": "MIT",

"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.*|5.0.*",
"symfony/finder": "~2.3",
"php": ">=5.4.0",
"illuminate/support": "5.0.*",
"symfony/finder": "~2.6",
"maximebf/debugbar": "~1.10.2"
},
"autoload": {
Expand All @@ -28,5 +27,6 @@
"branch-alias": {
"dev-master": "1.8-dev"
}
}
},
"minimum-stability": "dev"
}
File renamed without changes.
6 changes: 2 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Stable Version](https://poser.pugx.org/barryvdh/laravel-debugbar/version.png)](https://packagist.org/packages/barryvdh/laravel-debugbar)
[![Total Downloads](https://poser.pugx.org/barryvdh/laravel-debugbar/d/total.png)](https://packagist.org/packages/barryvdh/laravel-debugbar)

This is a package to integrate [PHP Debug Bar](http://phpdebugbar.com/) with Laravel.
This is a package to integrate [PHP Debug Bar](http://phpdebugbar.com/) with Laravel 5.
It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel.
It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel.
It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown)
Expand Down Expand Up @@ -58,9 +58,7 @@ If you want to use the facade to log messages, add this to your facades in app.p
'Debugbar' => 'Barryvdh\Debugbar\Facade',
```

~~You need to publish the assets from this package.~~ Since 1.7, you don't need to publish the assets anymore.

The profiler is enabled by default, if you have app.debug=true. You can override that in the config files.
The profiler is enabled by default, if you have app.debug=true. You can override that in the config (`debugbar.enabled`). See more options in `config/config.php`
You can also set in your config if you want to include/exclude the vendor files also (FontAwesome, Highlight.js and jQuery). If you already use them in your site, set it to false.
You can also only display the js of css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to `true` for syntax highlighting)

Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/OpenHandlerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use DebugBar\OpenHandler;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

class OpenHandlerController extends BaseController
class OpenHandlerController extends Controller
{
public function handle()
{
Expand Down
2 changes: 1 addition & 1 deletion src/DataCollector/IlluminateRouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function getWidgets()
"default" => "{}"
)
);
if (Config::get('laravel-debugbar::config.options.route.label', true)) {
if (Config::get('debugbar.options.route.label', true)) {
$widgets['currentroute'] = array(
"icon" => "share",
"tooltip" => "Route",
Expand Down
63 changes: 26 additions & 37 deletions src/LaravelDebugBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct($app = null)
*/
public function enable()
{
$this->app['config']->set('laravel-debugbar::config.enabled', true);
$this->app['config']->set('debugbar.enabled', true);
if (!$this->booted) {
$this->boot();
}
Expand Down Expand Up @@ -127,7 +127,7 @@ function () use ($debugbar, $startTime) {
);

//Check if App::before is already called..
if ($this->checkVersion('4.1-dev', '>=') && $this->app->isBooted()) {
if ($this->app->isBooted()) {
$debugbar->startMeasure('application', 'Application');
} else {
$this->app['router']->before(
Expand All @@ -151,16 +151,9 @@ function () use ($debugbar) {
try {
$exceptionCollector = new ExceptionsCollector();
$exceptionCollector->setChainExceptions(
$this->app['config']->get('laravel-debugbar::config.options.exceptions.chain', true)
$this->app['config']->get('debugbar.options.exceptions.chain', true)
);
$this->addCollector($exceptionCollector);
if ($this->checkVersion('5.0-dev', '<')) {
$this->app->error(
function (Exception $exception) use ($exceptionCollector) {
$exceptionCollector->addException($exception);
}
);
}
} catch (\Exception $e) {
}
}
Expand Down Expand Up @@ -191,7 +184,7 @@ function (Exception $exception) use ($exceptionCollector) {

if ($this->shouldCollect('views', true) and isset($this->app['events'])) {
try {
$collectData = $this->app['config']->get('laravel-debugbar::config.options.views.data', true);
$collectData = $this->app['config']->get('debugbar.options.views.data', true);
$this->addCollector(new ViewCollector($collectData));
$this->app['events']->listen(
'composing:*',
Expand All @@ -210,11 +203,7 @@ function ($view) use ($debugbar) {

if ($this->shouldCollect('route')) {
try {
if ($this->checkVersion('4.1', '>=')) {
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\IlluminateRouteCollector'));
} else {
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\SymfonyRouteCollector'));
}
$this->addCollector($this->app->make('Barryvdh\Debugbar\DataCollector\IlluminateRouteCollector'));
} catch (\Exception $e) {
$this->addException(
new Exception(
Expand Down Expand Up @@ -265,7 +254,7 @@ function ($level, $message, $context) use ($logger) {
if ($this->shouldCollect('db', true) and isset($this->app['db'])) {
$db = $this->app['db'];
if ($debugbar->hasCollector('time') && $this->app['config']->get(
'laravel-debugbar::config.options.db.timeline',
'debugbar.options.db.timeline',
false
)
) {
Expand All @@ -275,20 +264,20 @@ function ($level, $message, $context) use ($logger) {
}
$queryCollector = new QueryCollector($timeCollector);

if ($this->app['config']->get('laravel-debugbar::config.options.db.with_params')) {
if ($this->app['config']->get('debugbar.options.db.with_params')) {
$queryCollector->setRenderSqlWithParams(true);
}

if ($this->app['config']->get('laravel-debugbar::config.options.db.backtrace')) {
if ($this->app['config']->get('debugbar.options.db.backtrace')) {
$queryCollector->setFindSource(true);
}

if ($this->app['config']->get('laravel-debugbar::config.options.db.explain.enabled')) {
$types = $this->app['config']->get('laravel-debugbar::config.options.db.explain.types');
if ($this->app['config']->get('debugbar.options.db.explain.enabled')) {
$types = $this->app['config']->get('debugbar.options.db.explain.types');
$queryCollector->setExplainSource(true, $types);
}

if ($this->app['config']->get('laravel-debugbar::config.options.db.hints', true)) {
if ($this->app['config']->get('debugbar.options.db.hints', true)) {
$queryCollector->setShowHints(true);
}

Expand Down Expand Up @@ -316,7 +305,7 @@ function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector)
try {
$mailer = $this->app['mailer']->getSwiftMailer();
$this->addCollector(new SwiftMailCollector($mailer));
if ($this->app['config']->get('laravel-debugbar::config.options.mail.full_log') and $this->hasCollector(
if ($this->app['config']->get('debugbar.options.mail.full_log') and $this->hasCollector(
'messages'
)
) {
Expand All @@ -333,7 +322,7 @@ function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector)

if ($this->shouldCollect('logs', false)) {
try {
$file = $this->app['config']->get('laravel-debugbar::config.options.logs.file');
$file = $this->app['config']->get('debugbar.options.logs.file');
$this->addCollector(new LogsCollector($file));
} catch (\Exception $e) {
$this->addException(
Expand All @@ -351,7 +340,7 @@ function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector)
try {
$authCollector = new AuthCollector($app['auth']);
$authCollector->setShowName(
$this->app['config']->get('laravel-debugbar::config.options.auth.show_name')
$this->app['config']->get('debugbar.options.auth.show_name')
);
$this->addCollector($authCollector);
} catch (\Exception $e) {
Expand All @@ -364,15 +353,15 @@ function ($query, $bindings, $time, $connectionName) use ($db, $queryCollector)
}

$renderer = $this->getJavascriptRenderer();
$renderer->setIncludeVendors($this->app['config']->get('laravel-debugbar::config.include_vendors', true));
$renderer->setBindAjaxHandlerToXHR($app['config']->get('laravel-debugbar::config.capture_ajax', true));
$renderer->setIncludeVendors($this->app['config']->get('debugbar.include_vendors', true));
$renderer->setBindAjaxHandlerToXHR($app['config']->get('debugbar.capture_ajax', true));

$this->booted = true;
}

public function shouldCollect($name, $default = false)
{
return $this->app['config']->get('laravel-debugbar::config.collectors.' . $name, $default);
return $this->app['config']->get('debugbar.collectors.' . $name, $default);
}

/**
Expand Down Expand Up @@ -509,7 +498,7 @@ public function modifyResponse($request, $response)
}
} elseif (
($request->isXmlHttpRequest() || $request->wantsJson()) and
$app['config']->get('laravel-debugbar::config.capture_ajax', true)
$app['config']->get('debugbar.capture_ajax', true)
) {
try {
$this->sendDataInHeaders(true);
Expand All @@ -527,7 +516,7 @@ public function modifyResponse($request, $response)
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif ($app['config']->get('laravel-debugbar::config.inject', true)) {
} elseif ($app['config']->get('debugbar.inject', true)) {
try {
$this->injectDebugbar($response);
} catch (\Exception $e) {
Expand All @@ -547,7 +536,7 @@ public function modifyResponse($request, $response)
*/
public function isEnabled()
{
return value($this->app['config']->get('laravel-debugbar::config.enabled'));
return value($this->app['config']->get('debugbar.enabled'));
}

/**
Expand Down Expand Up @@ -635,7 +624,7 @@ public function injectDebugbar(Response $response)
*/
public function disable()
{
$this->app['config']->set('laravel-debugbar::config.enabled', false);
$this->app['config']->set('debugbar.enabled', false);
}

/**
Expand Down Expand Up @@ -764,23 +753,23 @@ protected function checkVersion($version, $operator = ">=")
protected function selectStorage(DebugBar $debugbar)
{
$config = $this->app['config'];
if ($config->get('laravel-debugbar::config.storage.enabled')) {
$driver = $config->get('laravel-debugbar::config.storage.driver', 'file');
if ($config->get('debugbar.storage.enabled')) {
$driver = $config->get('debugbar.storage.driver', 'file');

switch ($driver) {
case 'pdo':
$connection = $config->get('laravel-debugbar::config.storage.connection');
$connection = $config->get('debugbar.storage.connection');
$table = $this->app['db']->getTablePrefix() . 'phpdebugbar';
$pdo = $this->app['db']->connection($connection)->getPdo();
$storage = new PdoStorage($pdo, $table);
break;
case 'redis':
$connection = $config->get('laravel-debugbar::config.storage.connection');
$connection = $config->get('debugbar.storage.connection');
$storage = new RedisStorage($this->app['redis']->connection($connection));
break;
case 'file':
default:
$path = $config->get('laravel-debugbar::config.storage.path');
$path = $config->get('debugbar.storage.path');
$storage = new FilesystemStorage($this->app['files'], $path);
break;
}
Expand Down
38 changes: 0 additions & 38 deletions src/Middleware/Stack.php

This file was deleted.

Loading

0 comments on commit d4bc7b1

Please sign in to comment.