Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
class AuthCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/** @var \Illuminate\Auth\AuthManager */
|
||||
protected $auth;
|
||||
/** @var bool */
|
||||
protected $showName = false;
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Auth\AuthManager $auth
|
||||
*/
|
||||
public function __construct($auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to show the users name/email
|
||||
* @param bool $showName
|
||||
*/
|
||||
public function setShowName($showName)
|
||||
{
|
||||
$this->showName = (bool) $showName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
try {
|
||||
$user = $this->auth->user();
|
||||
} catch (\Exception $e) {
|
||||
$user = null;
|
||||
}
|
||||
return $this->getUserInformation($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayed user information
|
||||
* @param \Illuminate\Auth\UserInterface $user
|
||||
* @return array
|
||||
*/
|
||||
protected function getUserInformation($user = null)
|
||||
{
|
||||
// Defaults
|
||||
if (is_null($user)) {
|
||||
return [
|
||||
'name' => 'Guest',
|
||||
'user' => ['guest' => true],
|
||||
];
|
||||
}
|
||||
|
||||
// The default auth identifer is the ID number, which isn't all that
|
||||
// useful. Try username and email.
|
||||
$identifier = $user->getAuthIdentifier();
|
||||
if (is_numeric($identifier)) {
|
||||
try {
|
||||
if ($user->username) {
|
||||
$identifier = $user->username;
|
||||
} elseif ($user->email) {
|
||||
$identifier = $user->email;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $identifier,
|
||||
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$widgets = [
|
||||
'auth' => [
|
||||
'icon' => 'lock',
|
||||
'widget' => 'PhpDebugBar.Widgets.VariableListWidget',
|
||||
'map' => 'auth.user',
|
||||
'default' => '{}'
|
||||
]
|
||||
];
|
||||
if ($this->showName) {
|
||||
$widgets['auth.name'] = [
|
||||
'icon' => 'user',
|
||||
'tooltip' => 'Auth status',
|
||||
'map' => 'auth.name',
|
||||
'default' => '',
|
||||
];
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
}
|
95
vendor/barryvdh/laravel-debugbar/src/DataCollector/CacheCollector.php
vendored
Normal file
95
vendor/barryvdh/laravel-debugbar/src/DataCollector/CacheCollector.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Illuminate\Cache\Events\CacheEvent;
|
||||
use Illuminate\Cache\Events\CacheHit;
|
||||
use Illuminate\Cache\Events\CacheMissed;
|
||||
use Illuminate\Cache\Events\KeyForgotten;
|
||||
use Illuminate\Cache\Events\KeyWritten;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
|
||||
class CacheCollector extends TimeDataCollector
|
||||
{
|
||||
/** @var bool */
|
||||
protected $collectValues;
|
||||
|
||||
/** @var array */
|
||||
protected $classMap = [
|
||||
CacheHit::class => 'hit',
|
||||
CacheMissed::class => 'missed',
|
||||
KeyWritten::class => 'written',
|
||||
KeyForgotten::class => 'forgotten',
|
||||
];
|
||||
|
||||
public function __construct($requestStartTime = null, $collectValues)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->collectValues = $collectValues;
|
||||
}
|
||||
|
||||
public function onCacheEvent(CacheEvent $event)
|
||||
{
|
||||
$class = get_class($event);
|
||||
$params = get_object_vars($event);
|
||||
|
||||
$label = $this->classMap[$class];
|
||||
|
||||
if (isset($params['value'])) {
|
||||
if ($this->collectValues) {
|
||||
$params['value'] = htmlspecialchars($this->getDataFormatter()->formatVar($event->value));
|
||||
} else {
|
||||
unset($params['value']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($params['key']) && in_array($label, ['hit', 'written'])) {
|
||||
$params['delete'] = route('debugbar.cache.delete', [
|
||||
'key' => urlencode($params['key']),
|
||||
'tags' => !empty($params['tags']) ? json_encode($params['tags']) : '',
|
||||
]);
|
||||
}
|
||||
|
||||
$time = microtime(true);
|
||||
$this->addMeasure($label . "\t" . $event->key, $time, $time, $params);
|
||||
}
|
||||
|
||||
|
||||
public function subscribe(Dispatcher $dispatcher)
|
||||
{
|
||||
foreach ($this->classMap as $eventClass => $type) {
|
||||
$dispatcher->listen($eventClass, [$this, 'onCacheEvent']);
|
||||
}
|
||||
}
|
||||
|
||||
public function collect()
|
||||
{
|
||||
$data = parent::collect();
|
||||
$data['nb_measures'] = count($data['measures']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
public function getWidgets()
|
||||
{
|
||||
return [
|
||||
'cache' => [
|
||||
'icon' => 'clipboard',
|
||||
'widget' => 'PhpDebugBar.Widgets.LaravelCacheWidget',
|
||||
'map' => 'cache',
|
||||
'default' => '{}',
|
||||
],
|
||||
'cache:badge' => [
|
||||
'map' => 'cache.nb_measures',
|
||||
'default' => 'null',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,36 +1,25 @@
|
||||
<?php
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use Barryvdh\Debugbar\DataFormatter\SimpleFormatter;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
class EventCollector extends TimeDataCollector
|
||||
{
|
||||
/** @var Dispatcher */
|
||||
protected $events;
|
||||
|
||||
/** @var ValueExporter */
|
||||
protected $exporter;
|
||||
|
||||
public function __construct($requestStartTime = null)
|
||||
{
|
||||
parent::__construct($requestStartTime);
|
||||
|
||||
$this->exporter = new ValueExporter();
|
||||
$this->setDataFormatter(new SimpleFormatter());
|
||||
}
|
||||
|
||||
public function onWildcardEvent($name = null, $data = [])
|
||||
{
|
||||
// Pre-Laravel 5.4, using 'firing' to get the current event name.
|
||||
if (method_exists($this->events, 'firing')) {
|
||||
$name = $this->events->firing();
|
||||
|
||||
// Get the arguments passed to the event
|
||||
$data = func_get_args();
|
||||
}
|
||||
|
||||
$params = $this->prepareParams($data);
|
||||
$time = microtime(true);
|
||||
|
||||
@@ -63,7 +52,7 @@ class EventCollector extends TimeDataCollector
|
||||
$listener = $reflector->getName() . ' (' . $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . ')';
|
||||
} else {
|
||||
// Not sure if this is possible, but to prevent edge cases
|
||||
$listener = $this->formatVar($listener);
|
||||
$listener = $this->getDataFormatter()->formatVar($listener);
|
||||
}
|
||||
|
||||
$params['listeners.' . $i] = $listener;
|
||||
@@ -84,7 +73,7 @@ class EventCollector extends TimeDataCollector
|
||||
if (is_object($value) && Str::is('Illuminate\*\Events\*', get_class($value))) {
|
||||
$value = $this->prepareParams(get_object_vars($value));
|
||||
}
|
||||
$data[$key] = htmlentities($this->exporter->exportValue($value), ENT_QUOTES, 'UTF-8', false);
|
||||
$data[$key] = htmlentities($this->getDataFormatter()->formatVar($value), ENT_QUOTES, 'UTF-8', false);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@@ -4,18 +4,18 @@ namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
class FilesCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/** @var \Illuminate\Contracts\Foundation\Application */
|
||||
/** @var \Illuminate\Container\Container */
|
||||
protected $app;
|
||||
protected $basePath;
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @param \Illuminate\Container\Container $app
|
||||
*/
|
||||
public function __construct(Application $app = null)
|
||||
public function __construct(Container $app = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->basePath = base_path();
|
||||
|
@@ -2,40 +2,45 @@
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use Barryvdh\Debugbar\DataFormatter\SimpleFormatter;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
class GateCollector extends MessagesCollector
|
||||
{
|
||||
/** @var ValueExporter */
|
||||
protected $exporter;
|
||||
/**
|
||||
* @param Gate $gate
|
||||
*/
|
||||
public function __construct(Gate $gate)
|
||||
{
|
||||
parent::__construct('gate');
|
||||
$this->exporter = new ValueExporter();
|
||||
|
||||
if (method_exists($gate, 'after')) {
|
||||
$gate->after([$this, 'addCheck']);
|
||||
}
|
||||
$this->setDataFormatter(new SimpleFormatter());
|
||||
$gate->after([$this, 'addCheck']);
|
||||
}
|
||||
|
||||
public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
|
||||
public function addCheck(Authorizable $user = null, $ability, $result, $arguments = [])
|
||||
{
|
||||
$userKey = 'user';
|
||||
$userId = null;
|
||||
|
||||
if ($user) {
|
||||
$userKey = snake_case(class_basename($user));
|
||||
$userId = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->id;
|
||||
}
|
||||
|
||||
$label = $result ? 'success' : 'error';
|
||||
|
||||
$this->addMessage([
|
||||
'ability' => $ability,
|
||||
'result' => $result,
|
||||
'user' => $user->getAuthIdentifier(),
|
||||
'arguments' => $this->exporter->exportValue($arguments),
|
||||
$userKey => $userId,
|
||||
'arguments' => $this->getDataFormatter()->formatVar($arguments),
|
||||
], $label, false);
|
||||
}
|
||||
}
|
||||
|
@@ -2,28 +2,45 @@
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Auth\SessionGuard;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
class MultiAuthCollector extends AuthCollector
|
||||
class MultiAuthCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/** @var array $guards */
|
||||
protected $guards;
|
||||
|
||||
/** @var \Illuminate\Auth\AuthManager */
|
||||
protected $auth;
|
||||
/** @var bool */
|
||||
protected $showName = false;
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Auth\AuthManager $auth
|
||||
* @param array $guards
|
||||
*/
|
||||
public function __construct($auth, $guards)
|
||||
{
|
||||
parent::__construct($auth);
|
||||
$this->auth = $auth;
|
||||
$this->guards = $guards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to show the users name/email
|
||||
* @param bool $showName
|
||||
*/
|
||||
public function setShowName($showName)
|
||||
{
|
||||
$this->showName = (bool) $showName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
@@ -77,6 +94,49 @@ class MultiAuthCollector extends AuthCollector
|
||||
return $guard->user();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get displayed user information
|
||||
* @param \Illuminate\Auth\UserInterface $user
|
||||
* @return array
|
||||
*/
|
||||
protected function getUserInformation($user = null)
|
||||
{
|
||||
// Defaults
|
||||
if (is_null($user)) {
|
||||
return [
|
||||
'name' => 'Guest',
|
||||
'user' => ['guest' => true],
|
||||
];
|
||||
}
|
||||
|
||||
// The default auth identifer is the ID number, which isn't all that
|
||||
// useful. Try username and email.
|
||||
$identifier = $user->getAuthIdentifier();
|
||||
if (is_numeric($identifier)) {
|
||||
try {
|
||||
if ($user->username) {
|
||||
$identifier = $user->username;
|
||||
} elseif ($user->email) {
|
||||
$identifier = $user->email;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $identifier,
|
||||
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
@@ -102,4 +162,5 @@ class MultiAuthCollector extends AuthCollector
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -185,7 +185,7 @@ class QueryCollector extends PDOCollector
|
||||
*/
|
||||
protected function findSource()
|
||||
{
|
||||
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, 50);
|
||||
|
||||
$sources = [];
|
||||
|
||||
@@ -218,13 +218,9 @@ class QueryCollector extends PDOCollector
|
||||
return $frame;
|
||||
}
|
||||
|
||||
if (isset($trace['class']) && isset($trace['file']) && strpos(
|
||||
$trace['file'],
|
||||
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework'
|
||||
) === false && strpos(
|
||||
$trace['file'],
|
||||
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar'
|
||||
) === false
|
||||
if (isset($trace['class']) &&
|
||||
isset($trace['file']) &&
|
||||
!$this->fileIsInExcludedPath($trace['file'])
|
||||
) {
|
||||
$file = $trace['file'];
|
||||
|
||||
@@ -261,6 +257,31 @@ class QueryCollector extends PDOCollector
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given file is to be excluded from analysis
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
protected function fileIsInExcludedPath($file)
|
||||
{
|
||||
$excludedPaths = [
|
||||
'/vendor/laravel/framework/src/Illuminate/Database',
|
||||
'/vendor/laravel/framework/src/Illuminate/Events',
|
||||
'/vendor/barryvdh/laravel-debugbar',
|
||||
];
|
||||
|
||||
$normalizedPath = str_replace('\\', '/', $file);
|
||||
|
||||
foreach ($excludedPaths as $excludedPath) {
|
||||
if (strpos($normalizedPath, $excludedPath) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the middleware alias from the file.
|
||||
*
|
||||
|
@@ -12,7 +12,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* Based on \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector by Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
*/
|
||||
class SymfonyRequestCollector extends DataCollector implements DataCollectorInterface, Renderable
|
||||
class RequestCollector extends DataCollector implements DataCollectorInterface, Renderable
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Request $request */
|
||||
protected $request;
|
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Config;
|
||||
* https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Console/RoutesCommand.php
|
||||
*
|
||||
*/
|
||||
class IlluminateRouteCollector extends DataCollector implements Renderable
|
||||
class RouteCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/**
|
||||
* The router instance.
|
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use Barryvdh\Debugbar\DataFormatter\SimpleFormatter;
|
||||
use DebugBar\Bridge\Twig\TwigCollector;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
class ViewCollector extends TwigCollector
|
||||
{
|
||||
@@ -18,10 +19,10 @@ class ViewCollector extends TwigCollector
|
||||
*/
|
||||
public function __construct($collectData = true)
|
||||
{
|
||||
$this->setDataFormatter(new SimpleFormatter());
|
||||
$this->collect_data = $collectData;
|
||||
$this->name = 'views';
|
||||
$this->templates = [];
|
||||
$this->exporter = new ValueExporter();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@@ -75,17 +76,23 @@ class ViewCollector extends TwigCollector
|
||||
} else {
|
||||
$data = [];
|
||||
foreach ($view->getData() as $key => $value) {
|
||||
$data[$key] = $this->exporter->exportValue($value);
|
||||
$data[$key] = $this->getDataFormatter()->formatVar($value);
|
||||
}
|
||||
$params = $data;
|
||||
}
|
||||
|
||||
$this->templates[] = [
|
||||
$template = [
|
||||
'name' => $path ? sprintf('%s (%s)', $name, $path) : $name,
|
||||
'param_count' => count($params),
|
||||
'params' => $params,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
if ( $this->getXdebugLink($path)) {
|
||||
$template['xdebug_link'] = $this->getXdebugLink($path);
|
||||
}
|
||||
|
||||
$this->templates[] = $template;
|
||||
}
|
||||
|
||||
public function collect()
|
||||
|
Reference in New Issue
Block a user