update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
115
vendor/barryvdh/laravel-debugbar/src/DataCollector/AuthCollector.php
vendored
Normal file
115
vendor/barryvdh/laravel-debugbar/src/DataCollector/AuthCollector.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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 array(
|
||||
'name' => 'Guest',
|
||||
'user' => array('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 array(
|
||||
'name' => $identifier,
|
||||
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$widgets = array(
|
||||
'auth' => array(
|
||||
'icon' => 'lock',
|
||||
'widget' => 'PhpDebugBar.Widgets.VariableListWidget',
|
||||
'map' => 'auth.user',
|
||||
'default' => '{}'
|
||||
)
|
||||
);
|
||||
if ($this->showName) {
|
||||
$widgets['auth.name'] = array(
|
||||
'icon' => 'user',
|
||||
'tooltip' => 'Auth status',
|
||||
'map' => 'auth.name',
|
||||
'default' => '',
|
||||
);
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
}
|
116
vendor/barryvdh/laravel-debugbar/src/DataCollector/EventCollector.php
vendored
Normal file
116
vendor/barryvdh/laravel-debugbar/src/DataCollector/EventCollector.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
|
||||
class EventCollector extends TimeDataCollector
|
||||
{
|
||||
/** @var Dispatcher */
|
||||
protected $events;
|
||||
|
||||
/** @var ValueExporter */
|
||||
protected $exporter;
|
||||
|
||||
public function __construct($requestStartTime = null)
|
||||
{
|
||||
parent::__construct($requestStartTime);
|
||||
|
||||
$this->exporter = new ValueExporter();
|
||||
}
|
||||
|
||||
public function onWildcardEvent()
|
||||
{
|
||||
$name = $this->events->firing();
|
||||
$time = microtime(true);
|
||||
|
||||
// Get the arguments passed to the event
|
||||
$params = $this->prepareParams(func_get_args());
|
||||
|
||||
// Find all listeners for the current event
|
||||
foreach ($this->events->getListeners($name) as $i => $listener) {
|
||||
|
||||
// Check if it's an object + method name
|
||||
if (is_array($listener) && count($listener) > 1 && is_object($listener[0])) {
|
||||
list($class, $method) = $listener;
|
||||
|
||||
// Skip this class itself
|
||||
if ($class instanceof static) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Format the listener to readable format
|
||||
$listener = get_class($class) . '@' . $method;
|
||||
|
||||
// Handle closures
|
||||
} elseif ($listener instanceof \Closure) {
|
||||
$reflector = new \ReflectionFunction($listener);
|
||||
|
||||
// Skip our own listeners
|
||||
if ($reflector->getNamespaceName() == 'Barryvdh\Debugbar') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Format the closure to a readable format
|
||||
$filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/');
|
||||
$listener = $reflector->getName() . ' (' . $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . ')';
|
||||
} else {
|
||||
// Not sure if this is possible, but to prevent edge cases
|
||||
$listener = $this->formatVar($listener);
|
||||
}
|
||||
|
||||
$params['listeners.' . $i] = $listener;
|
||||
}
|
||||
$this->addMeasure($name, $time, $time, $params);
|
||||
}
|
||||
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$this->events = $events;
|
||||
$events->listen('*', array($this, 'onWildcardEvent'));
|
||||
}
|
||||
|
||||
protected function prepareParams($params)
|
||||
{
|
||||
$data = array();
|
||||
foreach ($params as $key => $value) {
|
||||
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);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function collect()
|
||||
{
|
||||
$data = parent::collect();
|
||||
$data['nb_measures'] = count($data['measures']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'event';
|
||||
}
|
||||
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"events" => array(
|
||||
"icon" => "tasks",
|
||||
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
|
||||
"map" => "event",
|
||||
"default" => "{}",
|
||||
),
|
||||
'events:badge' => array(
|
||||
'map' => 'event.nb_measures',
|
||||
'default' => 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
135
vendor/barryvdh/laravel-debugbar/src/DataCollector/FilesCollector.php
vendored
Normal file
135
vendor/barryvdh/laravel-debugbar/src/DataCollector/FilesCollector.php
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
class FilesCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/** @var \Illuminate\Contracts\Foundation\Application */
|
||||
protected $app;
|
||||
protected $basePath;
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
*/
|
||||
public function __construct(Application $app = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->basePath = base_path();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$files = $this->getIncludedFiles();
|
||||
$compiled = $this->getCompiledFiles();
|
||||
|
||||
$included = array();
|
||||
$alreadyCompiled = array();
|
||||
foreach ($files as $file) {
|
||||
// Skip the files from Debugbar, they are only loaded for Debugging and confuse the output.
|
||||
// Of course some files are stil always loaded (ServiceProvider, Facade etc)
|
||||
if (strpos($file, 'vendor/maximebf/debugbar/src') !== false || strpos(
|
||||
$file,
|
||||
'vendor/barryvdh/laravel-debugbar/src'
|
||||
) !== false
|
||||
) {
|
||||
continue;
|
||||
} elseif (!in_array($file, $compiled)) {
|
||||
$included[] = array(
|
||||
'message' => "'" . $this->stripBasePath($file) . "',",
|
||||
// Use PHP syntax so we can copy-paste to compile config file.
|
||||
'is_string' => true,
|
||||
);
|
||||
} else {
|
||||
$alreadyCompiled[] = array(
|
||||
'message' => "* '" . $this->stripBasePath($file) . "',",
|
||||
// Mark with *, so know they are compiled anyways.
|
||||
'is_string' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// First the included files, then those that are going to be compiled.
|
||||
$messages = array_merge($included, $alreadyCompiled);
|
||||
|
||||
return array(
|
||||
'messages' => $messages,
|
||||
'count' => count($included),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files included on load.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getIncludedFiles()
|
||||
{
|
||||
return get_included_files();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files that are going to be compiled, so they aren't as important.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCompiledFiles()
|
||||
{
|
||||
if ($this->app && class_exists('Illuminate\Foundation\Console\OptimizeCommand')) {
|
||||
$reflector = new \ReflectionClass('Illuminate\Foundation\Console\OptimizeCommand');
|
||||
$path = dirname($reflector->getFileName()) . '/Optimize/config.php';
|
||||
|
||||
if (file_exists($path)) {
|
||||
$app = $this->app;
|
||||
$core = require $path;
|
||||
return array_merge($core, $app['config']['compile']);
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the basePath from the paths, so they are relative to the base
|
||||
*
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
protected function stripBasePath($path)
|
||||
{
|
||||
return ltrim(str_replace($this->basePath, '', $path), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$name = $this->getName();
|
||||
return array(
|
||||
"$name" => array(
|
||||
"icon" => "files-o",
|
||||
"widget" => "PhpDebugBar.Widgets.MessagesWidget",
|
||||
"map" => "$name.messages",
|
||||
"default" => "{}"
|
||||
),
|
||||
"$name:badge" => array(
|
||||
"map" => "$name.count",
|
||||
"default" => "null"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'files';
|
||||
}
|
||||
}
|
37
vendor/barryvdh/laravel-debugbar/src/DataCollector/GateCollector.php
vendored
Normal file
37
vendor/barryvdh/laravel-debugbar/src/DataCollector/GateCollector.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
class GateCollector extends MessagesCollector
|
||||
{
|
||||
/**
|
||||
* @param Gate $gate
|
||||
*/
|
||||
public function __construct(Gate $gate)
|
||||
{
|
||||
parent::__construct('gate');
|
||||
|
||||
if (method_exists($gate, 'after')) {
|
||||
$gate->after([$this, 'addCheck']);
|
||||
}
|
||||
}
|
||||
|
||||
public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
|
||||
{
|
||||
$label = $result ? 'success' : 'error';
|
||||
|
||||
$this->addMessage([
|
||||
'ability' => $ability,
|
||||
'result' => $result,
|
||||
'user' => $user->getAuthIdentifier(),
|
||||
'arguments' => $arguments,
|
||||
], $label, false);
|
||||
}
|
||||
}
|
143
vendor/barryvdh/laravel-debugbar/src/DataCollector/IlluminateRouteCollector.php
vendored
Normal file
143
vendor/barryvdh/laravel-debugbar/src/DataCollector/IlluminateRouteCollector.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* Based on Illuminate\Foundation\Console\RoutesCommand for Taylor Otwell
|
||||
* https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Console/RoutesCommand.php
|
||||
*
|
||||
*/
|
||||
class IlluminateRouteCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/**
|
||||
* The router instance.
|
||||
*
|
||||
* @var \Illuminate\Routing\Router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
public function __construct(Router $router)
|
||||
{
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$route = $this->router->current();
|
||||
return $this->getRouteInformation($route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the route information for a given route.
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @return array
|
||||
*/
|
||||
protected function getRouteInformation($route)
|
||||
{
|
||||
if (!is_a($route, 'Illuminate\Routing\Route')) {
|
||||
return array();
|
||||
}
|
||||
$uri = head($route->methods()) . ' ' . $route->uri();
|
||||
$action = $route->getAction();
|
||||
|
||||
$result = array(
|
||||
'uri' => $uri ?: '-',
|
||||
);
|
||||
|
||||
$result = array_merge($result, $action);
|
||||
|
||||
|
||||
if (isset($action['controller']) && strpos($action['controller'], '@') !== false) {
|
||||
list($controller, $method) = explode('@', $action['controller']);
|
||||
if(class_exists($controller) && method_exists($controller, $method)) {
|
||||
$reflector = new \ReflectionMethod($controller, $method);
|
||||
}
|
||||
unset($result['uses']);
|
||||
} elseif (isset($action['uses']) && $action['uses'] instanceof \Closure) {
|
||||
$reflector = new \ReflectionFunction($action['uses']);
|
||||
$result['uses'] = $this->formatVar($result['uses']);
|
||||
}
|
||||
|
||||
if (isset($reflector)) {
|
||||
$filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/');
|
||||
$result['file'] = $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine();
|
||||
}
|
||||
|
||||
if ($middleware = $this->getMiddleware($route)) {
|
||||
$result['middleware'] = $middleware;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get middleware
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @return string
|
||||
*/
|
||||
protected function getMiddleware($route)
|
||||
{
|
||||
$middleware = array_keys($route->middleware());
|
||||
|
||||
return implode(', ', $middleware);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'route';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$widgets = array(
|
||||
"route" => array(
|
||||
"icon" => "share",
|
||||
"widget" => "PhpDebugBar.Widgets.VariableListWidget",
|
||||
"map" => "route",
|
||||
"default" => "{}"
|
||||
)
|
||||
);
|
||||
if (Config::get('debugbar.options.route.label', true)) {
|
||||
$widgets['currentroute'] = array(
|
||||
"icon" => "share",
|
||||
"tooltip" => "Route",
|
||||
"map" => "route.uri",
|
||||
"default" => ""
|
||||
);
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the route information on the console.
|
||||
*
|
||||
* @param array $routes
|
||||
* @return void
|
||||
*/
|
||||
protected function displayRoutes(array $routes)
|
||||
{
|
||||
$this->table->setHeaders($this->headers)->setRows($routes);
|
||||
|
||||
$this->table->render($this->getOutput());
|
||||
}
|
||||
}
|
71
vendor/barryvdh/laravel-debugbar/src/DataCollector/LaravelCollector.php
vendored
Normal file
71
vendor/barryvdh/laravel-debugbar/src/DataCollector/LaravelCollector.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
class LaravelCollector extends DataCollector implements Renderable
|
||||
{
|
||||
/** @var \Illuminate\Foundation\Application $app */
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
*/
|
||||
public function __construct(Application $app = null)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
// Fallback if not injected
|
||||
$app = $this->app ?: app();
|
||||
|
||||
return array(
|
||||
"version" => $app::VERSION,
|
||||
"environment" => $app->environment(),
|
||||
"locale" => $app->getLocale(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'laravel';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"version" => array(
|
||||
"icon" => "github",
|
||||
"tooltip" => "Version",
|
||||
"map" => "laravel.version",
|
||||
"default" => ""
|
||||
),
|
||||
"environment" => array(
|
||||
"icon" => "desktop",
|
||||
"tooltip" => "Environment",
|
||||
"map" => "laravel.environment",
|
||||
"default" => ""
|
||||
),
|
||||
"locale" => array(
|
||||
"icon" => "flag",
|
||||
"tooltip" => "Current locale",
|
||||
"map" => "laravel.locale",
|
||||
"default" => "",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
142
vendor/barryvdh/laravel-debugbar/src/DataCollector/LogsCollector.php
vendored
Normal file
142
vendor/barryvdh/laravel-debugbar/src/DataCollector/LogsCollector.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use Psr\Log\LogLevel;
|
||||
use ReflectionClass;
|
||||
|
||||
class LogsCollector extends MessagesCollector
|
||||
{
|
||||
protected $lines = 124;
|
||||
|
||||
public function __construct($path = null, $name = 'logs')
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$path = $path ?: $this->getLogsFile();
|
||||
$this->getStorageLogs($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the logs file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLogsFile()
|
||||
{
|
||||
// default daily rotating logs (Laravel 5.0)
|
||||
$path = storage_path() . '/logs/laravel-' . date('Y-m-d') . '.log';
|
||||
|
||||
// single file logs
|
||||
if (!file_exists($path)) {
|
||||
$path = storage_path() . '/logs/laravel.log';
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* get logs apache in app/storage/logs
|
||||
* only 24 last of current day
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStorageLogs($path)
|
||||
{
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Load the latest lines, guessing about 15x the number of log entries (for stack traces etc)
|
||||
$file = implode("", $this->tailFile($path, $this->lines));
|
||||
|
||||
foreach ($this->getLogs($file) as $log) {
|
||||
$this->addMessage($log['header'] . $log['stack'], $log['level'], false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By Ain Tohvri (ain)
|
||||
* http://tekkie.flashbit.net/php/tail-functionality-in-php
|
||||
* @param string $file
|
||||
* @param int $lines
|
||||
* @return array
|
||||
*/
|
||||
protected function tailFile($file, $lines)
|
||||
{
|
||||
$handle = fopen($file, "r");
|
||||
$linecounter = $lines;
|
||||
$pos = -2;
|
||||
$beginning = false;
|
||||
$text = array();
|
||||
while ($linecounter > 0) {
|
||||
$t = " ";
|
||||
while ($t != "\n") {
|
||||
if (fseek($handle, $pos, SEEK_END) == -1) {
|
||||
$beginning = true;
|
||||
break;
|
||||
}
|
||||
$t = fgetc($handle);
|
||||
$pos--;
|
||||
}
|
||||
$linecounter--;
|
||||
if ($beginning) {
|
||||
rewind($handle);
|
||||
}
|
||||
$text[$lines - $linecounter - 1] = fgets($handle);
|
||||
if ($beginning) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
return array_reverse($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a string for log entries
|
||||
* Based on https://github.com/mikemand/logviewer/blob/master/src/Kmd/Logviewer/Logviewer.php by mikemand
|
||||
*
|
||||
* @param $file
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs($file)
|
||||
{
|
||||
$pattern = "/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/";
|
||||
|
||||
$log_levels = $this->getLevels();
|
||||
|
||||
// There has GOT to be a better way of doing this...
|
||||
preg_match_all($pattern, $file, $headings);
|
||||
$log_data = preg_split($pattern, $file);
|
||||
|
||||
$log = array();
|
||||
foreach ($headings as $h) {
|
||||
for ($i = 0, $j = count($h); $i < $j; $i++) {
|
||||
foreach ($log_levels as $ll) {
|
||||
if (strpos(strtolower($h[$i]), strtolower('.' . $ll))) {
|
||||
$log[] = array('level' => $ll, 'header' => $h[$i], 'stack' => $log_data[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$log = array_reverse($log);
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log levels from psr/log.
|
||||
* Based on https://github.com/mikemand/logviewer/blob/master/src/Kmd/Logviewer/Logviewer.php by mikemand
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getLevels()
|
||||
{
|
||||
$class = new ReflectionClass(new LogLevel());
|
||||
return $class->getConstants();
|
||||
}
|
||||
}
|
76
vendor/barryvdh/laravel-debugbar/src/DataCollector/MultiAuthCollector.php
vendored
Normal file
76
vendor/barryvdh/laravel-debugbar/src/DataCollector/MultiAuthCollector.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
/**
|
||||
* Collector for Laravel's Auth provider
|
||||
*/
|
||||
class MultiAuthCollector extends AuthCollector
|
||||
{
|
||||
/** @var array $guards */
|
||||
protected $guards;
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Auth\AuthManager $auth
|
||||
* @param array $guards
|
||||
*/
|
||||
public function __construct($auth, $guards)
|
||||
{
|
||||
parent::__construct($auth);
|
||||
$this->guards = $guards;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$data = [];
|
||||
$names = '';
|
||||
|
||||
foreach($this->guards as $guardName) {
|
||||
$user = $this->auth->guard($guardName)->user();
|
||||
$data['guards'][$guardName] = $this->getUserInformation($user);
|
||||
if(!is_null($user)) {
|
||||
$names .= $guardName . ": " . $data['guards'][$guardName]['name'] . ', ';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data['guards'] as $key => $var) {
|
||||
if (!is_string($data['guards'][$key])) {
|
||||
$data['guards'][$key] = $this->formatVar($var);
|
||||
}
|
||||
}
|
||||
|
||||
$data['names'] = rtrim($names, ', ');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$widgets = array(
|
||||
"auth" => array(
|
||||
"icon" => "lock",
|
||||
"widget" => "PhpDebugBar.Widgets.VariableListWidget",
|
||||
"map" => "auth.guards",
|
||||
"default" => "{}"
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->showName) {
|
||||
$widgets['auth.name'] = array(
|
||||
'icon' => 'user',
|
||||
'tooltip' => 'Auth status',
|
||||
'map' => 'auth.names',
|
||||
'default' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
}
|
354
vendor/barryvdh/laravel-debugbar/src/DataCollector/QueryCollector.php
vendored
Normal file
354
vendor/barryvdh/laravel-debugbar/src/DataCollector/QueryCollector.php
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\PDO\PDOCollector;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
|
||||
/**
|
||||
* Collects data about SQL statements executed with PDO
|
||||
*/
|
||||
class QueryCollector extends PDOCollector
|
||||
{
|
||||
protected $timeCollector;
|
||||
protected $queries = array();
|
||||
protected $renderSqlWithParams = false;
|
||||
protected $findSource = false;
|
||||
protected $explainQuery = false;
|
||||
protected $explainTypes = array('SELECT'); // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
|
||||
protected $showHints = false;
|
||||
|
||||
/**
|
||||
* @param TimeDataCollector $timeCollector
|
||||
*/
|
||||
public function __construct(TimeDataCollector $timeCollector = null)
|
||||
{
|
||||
$this->timeCollector = $timeCollector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the SQL of traced statements with params embedded
|
||||
*
|
||||
* @param boolean $enabled
|
||||
* @param string $quotationChar NOT USED
|
||||
*/
|
||||
public function setRenderSqlWithParams($enabled = true, $quotationChar = "'")
|
||||
{
|
||||
$this->renderSqlWithParams = $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the hints in the parameters
|
||||
*
|
||||
* @param boolean $enabled
|
||||
*/
|
||||
public function setShowHints($enabled = true)
|
||||
{
|
||||
$this->showHints = $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable finding the source
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setFindSource($value = true)
|
||||
{
|
||||
$this->findSource = (bool) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable the EXPLAIN queries
|
||||
*
|
||||
* @param bool $enabled
|
||||
* @param array|null $types Array of types to explain queries (select/insert/update/delete)
|
||||
*/
|
||||
public function setExplainSource($enabled, $types)
|
||||
{
|
||||
$this->explainQuery = $enabled;
|
||||
if($types){
|
||||
$this->explainTypes = $types;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @param float $time
|
||||
* @param \Illuminate\Database\Connection $connection
|
||||
*/
|
||||
public function addQuery($query, $bindings, $time, $connection)
|
||||
{
|
||||
$explainResults = array();
|
||||
$time = $time / 1000;
|
||||
$endTime = microtime(true);
|
||||
$startTime = $endTime - $time;
|
||||
$hints = $this->performQueryAnalysis($query);
|
||||
|
||||
$pdo = $connection->getPdo();
|
||||
$bindings = $connection->prepareBindings($bindings);
|
||||
|
||||
// Run EXPLAIN on this query (if needed)
|
||||
if ($this->explainQuery && preg_match('/^('.implode($this->explainTypes).') /i', $query)) {
|
||||
$statement = $pdo->prepare('EXPLAIN ' . $query);
|
||||
$statement->execute($bindings);
|
||||
$explainResults = $statement->fetchAll(\PDO::FETCH_CLASS);
|
||||
}
|
||||
|
||||
$bindings = $this->checkBindings($bindings);
|
||||
if (!empty($bindings) && $this->renderSqlWithParams) {
|
||||
foreach ($bindings as $binding) {
|
||||
$query = preg_replace('/\?/', $pdo->quote($binding), $query, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$source = null;
|
||||
if ($this->findSource) {
|
||||
try {
|
||||
$source = $this->findSource();
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
$this->queries[] = array(
|
||||
'query' => $query,
|
||||
'bindings' => $this->escapeBindings($bindings),
|
||||
'time' => $time,
|
||||
'source' => $source,
|
||||
'explain' => $explainResults,
|
||||
'connection' => $connection->getDatabaseName(),
|
||||
'hints' => $this->showHints ? $hints : null,
|
||||
);
|
||||
|
||||
if ($this->timeCollector !== null) {
|
||||
$this->timeCollector->addMeasure($query, $startTime, $endTime);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check bindings for illegal (non UTF-8) strings, like Binary data.
|
||||
*
|
||||
* @param $bindings
|
||||
* @return mixed
|
||||
*/
|
||||
protected function checkBindings($bindings)
|
||||
{
|
||||
foreach ($bindings as &$binding) {
|
||||
if (is_string($binding) && !mb_check_encoding($binding, 'UTF-8')) {
|
||||
$binding = '[BINARY DATA]';
|
||||
}
|
||||
}
|
||||
return $bindings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the bindings safe for outputting.
|
||||
*
|
||||
* @param array $bindings
|
||||
* @return array
|
||||
*/
|
||||
protected function escapeBindings($bindings)
|
||||
{
|
||||
foreach ($bindings as &$binding) {
|
||||
$binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false);
|
||||
}
|
||||
return $bindings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explainer::performQueryAnalysis()
|
||||
*
|
||||
* Perform simple regex analysis on the code
|
||||
*
|
||||
* @package xplain (https://github.com/rap2hpoutre/mysql-xplain-xplain)
|
||||
* @author e-doceo
|
||||
* @copyright 2014
|
||||
* @version $Id$
|
||||
* @access public
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
protected function performQueryAnalysis($query)
|
||||
{
|
||||
$hints = array();
|
||||
if (preg_match('/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i', $query)) {
|
||||
$hints[] = 'Use <code>SELECT *</code> only if you need all columns from table';
|
||||
}
|
||||
if (preg_match('/ORDER BY RAND()/i', $query)) {
|
||||
$hints[] = '<code>ORDER BY RAND()</code> is slow, try to avoid if you can.
|
||||
You can <a href="http://stackoverflow.com/questions/2663710/how-does-mysqls-order-by-rand-work" target="_blank">read this</a>
|
||||
or <a href="http://stackoverflow.com/questions/1244555/how-can-i-optimize-mysqls-order-by-rand-function" target="_blank">this</a>';
|
||||
}
|
||||
if (strpos($query, '!=') !== false) {
|
||||
$hints[] = 'The <code>!=</code> operator is not standard. Use the <code><></code> operator to test for inequality instead.';
|
||||
}
|
||||
if (stripos($query, 'WHERE') === false && preg_match('/^(SELECT) /i', $query)) {
|
||||
$hints[] = 'The <code>SELECT</code> statement has no <code>WHERE</code> clause and could examine many more rows than intended';
|
||||
}
|
||||
if (preg_match('/LIMIT\\s/i', $query) && stripos($query, 'ORDER BY') === false) {
|
||||
$hints[] = '<code>LIMIT</code> without <code>ORDER BY</code> causes non-deterministic results, depending on the query execution plan';
|
||||
}
|
||||
if (preg_match('/LIKE\\s[\'"](%.*?)[\'"]/i', $query, $matches)) {
|
||||
$hints[] = 'An argument has a leading wildcard character: <code>' . $matches[1]. '</code>.
|
||||
The predicate with this argument is not sargable and cannot use an index if one exists.';
|
||||
}
|
||||
return implode("<br />", $hints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a backtrace to search for the origin of the query.
|
||||
*/
|
||||
protected function findSource()
|
||||
{
|
||||
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
foreach ($traces as $trace) {
|
||||
if (isset($trace['class']) && isset($trace['file']) && strpos(
|
||||
$trace['file'],
|
||||
DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR
|
||||
) === false
|
||||
) {
|
||||
if (isset($trace['object']) && is_a($trace['object'], 'Twig_Template')) {
|
||||
list($file, $line) = $this->getTwigInfo($trace);
|
||||
} elseif (strpos($trace['file'], storage_path()) !== false) {
|
||||
return 'Template file';
|
||||
} else {
|
||||
$file = $trace['file'];
|
||||
$line = isset($trace['line']) ? $trace['line'] : '?';
|
||||
}
|
||||
|
||||
return $this->normalizeFilename($file) . ':' . $line;
|
||||
} elseif (isset($trace['function']) && $trace['function'] == 'Illuminate\Routing\{closure}') {
|
||||
return 'Route binding';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename/line from a Twig template trace
|
||||
*
|
||||
* @param array $trace
|
||||
* @return array The file and line
|
||||
*/
|
||||
protected function getTwigInfo($trace)
|
||||
{
|
||||
$file = $trace['object']->getTemplateName();
|
||||
|
||||
if (isset($trace['line'])) {
|
||||
foreach ($trace['object']->getDebugInfo() as $codeLine => $templateLine) {
|
||||
if ($codeLine <= $trace['line']) {
|
||||
return array($file, $templateLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array($file, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorten the path by removing the relative links and base dir
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizeFilename($path)
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
$path = realpath($path);
|
||||
}
|
||||
return str_replace(base_path(), '', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the queries.
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->queries = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$totalTime = 0;
|
||||
$queries = $this->queries;
|
||||
|
||||
$statements = array();
|
||||
foreach ($queries as $query) {
|
||||
$totalTime += $query['time'];
|
||||
|
||||
$bindings = $query['bindings'];
|
||||
if($query['hints']){
|
||||
$bindings['hints'] = $query['hints'];
|
||||
}
|
||||
|
||||
$statements[] = array(
|
||||
'sql' => $this->formatSql($query['query']),
|
||||
'params' => (object) $bindings,
|
||||
'duration' => $query['time'],
|
||||
'duration_str' => $this->formatDuration($query['time']),
|
||||
'stmt_id' => $query['source'],
|
||||
'connection' => $query['connection'],
|
||||
);
|
||||
|
||||
//Add the results from the explain as new rows
|
||||
foreach($query['explain'] as $explain){
|
||||
$statements[] = array(
|
||||
'sql' => ' - EXPLAIN #' . $explain->id . ': `' . $explain->table . '` (' . $explain->select_type . ')',
|
||||
'params' => $explain,
|
||||
'row_count' => $explain->rows,
|
||||
'stmt_id' => $explain->id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'nb_statements' => count($queries),
|
||||
'nb_failed_statements' => 0,
|
||||
'accumulated_duration' => $totalTime,
|
||||
'accumulated_duration_str' => $this->formatDuration($totalTime),
|
||||
'statements' => $statements
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes extra spaces at the beginning and end of the SQL query and its lines.
|
||||
*
|
||||
* @param string $sql
|
||||
* @return string
|
||||
*/
|
||||
protected function formatSql($sql)
|
||||
{
|
||||
return trim(preg_replace("/\s*\n\s*/", "\n", $sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'queries';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"queries" => array(
|
||||
"icon" => "inbox",
|
||||
"widget" => "PhpDebugBar.Widgets.SQLQueriesWidget",
|
||||
"map" => "queries",
|
||||
"default" => "[]"
|
||||
),
|
||||
"queries:badge" => array(
|
||||
"map" => "queries.nb_statements",
|
||||
"default" => 0
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
58
vendor/barryvdh/laravel-debugbar/src/DataCollector/SessionCollector.php
vendored
Normal file
58
vendor/barryvdh/laravel-debugbar/src/DataCollector/SessionCollector.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\DataCollectorInterface;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
|
||||
class SessionCollector extends DataCollector implements DataCollectorInterface, Renderable
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* Create a new SessionCollector
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
|
||||
*/
|
||||
public function __construct($session)
|
||||
{
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$data = array();
|
||||
foreach ($this->session->all() as $key => $value) {
|
||||
$data[$key] = is_string($value) ? $value : $this->formatVar($value);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'session';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"session" => array(
|
||||
"icon" => "archive",
|
||||
"widget" => "PhpDebugBar.Widgets.VariableListWidget",
|
||||
"map" => "session",
|
||||
"default" => "{}"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
177
vendor/barryvdh/laravel-debugbar/src/DataCollector/SymfonyRequestCollector.php
vendored
Normal file
177
vendor/barryvdh/laravel-debugbar/src/DataCollector/SymfonyRequestCollector.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\DataCollectorInterface;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
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
|
||||
{
|
||||
/** @var \Symfony\Component\HttpFoundation\Request $request */
|
||||
protected $request;
|
||||
/** @var \Symfony\Component\HttpFoundation\Request $response */
|
||||
protected $response;
|
||||
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* Create a new SymfonyRequestCollector
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param \Symfony\Component\HttpFoundation\Request $response
|
||||
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
|
||||
*/
|
||||
public function __construct($request, $response, $session = null)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'request';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
"request" => array(
|
||||
"icon" => "tags",
|
||||
"widget" => "PhpDebugBar.Widgets.VariableListWidget",
|
||||
"map" => "request",
|
||||
"default" => "{}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$request = $this->request;
|
||||
$response = $this->response;
|
||||
|
||||
$responseHeaders = $response->headers->all();
|
||||
$cookies = array();
|
||||
foreach ($response->headers->getCookies() as $cookie) {
|
||||
$cookies[] = $this->getCookieHeader(
|
||||
$cookie->getName(),
|
||||
$cookie->getValue(),
|
||||
$cookie->getExpiresTime(),
|
||||
$cookie->getPath(),
|
||||
$cookie->getDomain(),
|
||||
$cookie->isSecure(),
|
||||
$cookie->isHttpOnly()
|
||||
);
|
||||
}
|
||||
if (count($cookies) > 0) {
|
||||
$responseHeaders['Set-Cookie'] = $cookies;
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
$data = array(
|
||||
'format' => $request->getRequestFormat(),
|
||||
'content_type' => $response->headers->get('Content-Type') ? $response->headers->get(
|
||||
'Content-Type'
|
||||
) : 'text/html',
|
||||
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
|
||||
'status_code' => $statusCode,
|
||||
'request_query' => $request->query->all(),
|
||||
'request_request' => $request->request->all(),
|
||||
'request_headers' => $request->headers->all(),
|
||||
'request_server' => $request->server->all(),
|
||||
'request_cookies' => $request->cookies->all(),
|
||||
'response_headers' => $responseHeaders,
|
||||
'path_info' => $request->getPathInfo(),
|
||||
);
|
||||
|
||||
if ($this->session) {
|
||||
$sessionAttributes = array();
|
||||
foreach ($this->session->all() as $key => $value) {
|
||||
$sessionAttributes[$key] = $value;
|
||||
}
|
||||
$data['session_attributes'] = $sessionAttributes;
|
||||
}
|
||||
|
||||
foreach ($data['request_server'] as $key => $value) {
|
||||
if (str_is('*_KEY', $key) || str_is('*_PASSWORD', $key)
|
||||
|| str_is('*_SECRET', $key) || str_is('*_PW', $key)) {
|
||||
$data['request_server'][$key] = '******';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['request_headers']['php-auth-pw'])) {
|
||||
$data['request_headers']['php-auth-pw'] = '******';
|
||||
}
|
||||
|
||||
if (isset($data['request_server']['PHP_AUTH_PW'])) {
|
||||
$data['request_server']['PHP_AUTH_PW'] = '******';
|
||||
}
|
||||
|
||||
foreach ($data as $key => $var) {
|
||||
if (!is_string($data[$key])) {
|
||||
$data[$key] = $this->formatVar($var);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly)
|
||||
{
|
||||
$cookie = sprintf('%s=%s', $name, urlencode($value));
|
||||
|
||||
if (0 !== $expires) {
|
||||
if (is_numeric($expires)) {
|
||||
$expires = (int) $expires;
|
||||
} elseif ($expires instanceof \DateTime) {
|
||||
$expires = $expires->getTimestamp();
|
||||
} else {
|
||||
$expires = strtotime($expires);
|
||||
if (false === $expires || -1 == $expires) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('The "expires" cookie parameter is not valid.', $expires)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$cookie .= '; expires=' . substr(
|
||||
\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'),
|
||||
0,
|
||||
-5
|
||||
);
|
||||
}
|
||||
|
||||
if ($domain) {
|
||||
$cookie .= '; domain=' . $domain;
|
||||
}
|
||||
|
||||
$cookie .= '; path=' . $path;
|
||||
|
||||
if ($secure) {
|
||||
$cookie .= '; secure';
|
||||
}
|
||||
|
||||
if ($httponly) {
|
||||
$cookie .= '; httponly';
|
||||
}
|
||||
|
||||
return $cookie;
|
||||
}
|
||||
}
|
100
vendor/barryvdh/laravel-debugbar/src/DataCollector/ViewCollector.php
vendored
Normal file
100
vendor/barryvdh/laravel-debugbar/src/DataCollector/ViewCollector.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Barryvdh\Debugbar\DataCollector;
|
||||
|
||||
use DebugBar\Bridge\Twig\TwigCollector;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
|
||||
class ViewCollector extends TwigCollector
|
||||
{
|
||||
protected $templates = array();
|
||||
protected $collect_data;
|
||||
|
||||
/**
|
||||
* Create a ViewCollector
|
||||
*
|
||||
* @param bool $collectData Collects view data when tru
|
||||
*/
|
||||
public function __construct($collectData = true)
|
||||
{
|
||||
$this->collect_data = $collectData;
|
||||
$this->name = 'views';
|
||||
$this->templates = array();
|
||||
$this->exporter = new ValueExporter();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'views';
|
||||
}
|
||||
|
||||
public function getWidgets()
|
||||
{
|
||||
return array(
|
||||
'views' => array(
|
||||
'icon' => 'leaf',
|
||||
'widget' => 'PhpDebugBar.Widgets.TemplatesWidget',
|
||||
'map' => 'views',
|
||||
'default' => '[]'
|
||||
),
|
||||
'views:badge' => array(
|
||||
'map' => 'views.nb_templates',
|
||||
'default' => 0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a View instance to the Collector
|
||||
*
|
||||
* @param \Illuminate\View\View $view
|
||||
*/
|
||||
public function addView(View $view)
|
||||
{
|
||||
$name = $view->getName();
|
||||
$path = $view->getPath();
|
||||
|
||||
if (!is_object($path)) {
|
||||
if ($path) {
|
||||
$path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
|
||||
}
|
||||
|
||||
if (substr($path, -10) == '.blade.php') {
|
||||
$type = 'blade';
|
||||
} else {
|
||||
$type = pathinfo($path, PATHINFO_EXTENSION);
|
||||
}
|
||||
} else {
|
||||
$type = get_class($view);
|
||||
$path = '';
|
||||
}
|
||||
|
||||
if (!$this->collect_data) {
|
||||
$params = array_keys($view->getData());
|
||||
} else {
|
||||
$data = array();
|
||||
foreach ($view->getData() as $key => $value) {
|
||||
$data[$key] = $this->exporter->exportValue($value);
|
||||
}
|
||||
$params = $data;
|
||||
}
|
||||
|
||||
$this->templates[] = array(
|
||||
'name' => $path ? sprintf('%s (%s)', $name, $path) : $name,
|
||||
'param_count' => count($params),
|
||||
'params' => $params,
|
||||
'type' => $type,
|
||||
);
|
||||
}
|
||||
|
||||
public function collect()
|
||||
{
|
||||
$templates = $this->templates;
|
||||
|
||||
return array(
|
||||
'nb_templates' => count($templates),
|
||||
'templates' => $templates,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user