From 75c100fbce4916d440edf1922fc7c3f2e2155e52 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 12 Jul 2015 17:08:59 +0200 Subject: [PATCH 1/9] Test Clockwork output --- config/debugbar.php | 11 ++ src/Controllers/OpenHandlerController.php | 32 +++++ src/ServiceProvider.php | 10 ++ src/Support/Clockwork/Converter.php | 142 ++++++++++++++++++++++ src/Support/Clockwork/Middleware.php | 69 +++++++++++ 5 files changed, 264 insertions(+) create mode 100644 src/Support/Clockwork/Converter.php create mode 100644 src/Support/Clockwork/Middleware.php diff --git a/config/debugbar.php b/config/debugbar.php index 0872e870..9328fcf7 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -61,6 +61,17 @@ 'capture_ajax' => true, + /* + |-------------------------------------------------------------------------- + | Clockwork integration + |-------------------------------------------------------------------------- + | + | The Debugbar can emulate the Clockwork headers, so you can use the Chrome + | Extension, without the server-side code. It uses Debugbar collectors instead. + | + */ + 'clockwork' => false, + /* |-------------------------------------------------------------------------- | DataCollectors diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 7135727f..479d8828 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -1,5 +1,6 @@ 'get', + 'id' => $id, + ]; + + $debugbar = $this->debugbar; + + if (!$debugbar->isEnabled()) { + $this->app->abort('500', 'Debugbar is not enabled'); + } + + $openHandler = new OpenHandler($debugbar); + + $data = $openHandler->handle($request, false, false); + + // Convert to Clockwork + $converter = new Converter(); + $output = $converter->convert(json_decode($data, true)); + + return response()->json($output); + } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index b7bbfb25..04765986 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -73,6 +73,11 @@ public function boot() 'uses' => 'OpenHandlerController@handle', 'as' => 'debugbar.openhandler', ]); + + $router->get('clockwork/{id?}', [ + 'uses' => 'OpenHandlerController@clockwork', + 'as' => 'debugbar.clockwork', + ]); $router->get('assets/stylesheets', [ 'uses' => 'AssetController@css', @@ -102,6 +107,11 @@ public function boot() $debugbar->boot(); $kernel = $this->app['Illuminate\Contracts\Http\Kernel']; + + if ($this->app['config']->get('debugbar.clockwork')) { + $kernel->pushMiddleware('Barryvdh\Debugbar\Support\Clockwork\Middleware'); + } + $kernel->pushMiddleware('Barryvdh\Debugbar\Middleware\Debugbar'); } diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php new file mode 100644 index 00000000..9025c1ac --- /dev/null +++ b/src/Support/Clockwork/Converter.php @@ -0,0 +1,142 @@ + $meta['id'], + 'method' => $meta['method'], + 'uri' => $meta['uri'], + 'time' => $meta['utime'], + 'headers' => [], + 'cookies' => [], + 'emailsData' => [], + 'getData' => [], + 'headers' => [], + 'log' => [], + 'postData' => [], + 'sessionData' => [], + 'timelineData' => [], + 'viewsData' => [], + 'controller' => null, + 'responseTime' => null, + 'responseStatus' => null, + 'responseDuration' => 0, + 'log' => [], + ]; + + + if (isset($data['time'])) { + $time = $data['time']; + $output['responseTime'] = $time['end']; + $output['responseDuration'] = $time['duration'] * 1000; + } + + if (isset($data['route'])) { + $route = $data['route']; + + if (isset($route['uses'])) { + $output['controller'] = $route['uses']; + } + } + + if (isset($data['messages'])) { + $messages = $data['messages']; + $output['messages'] = $messages['messages']; + } + + if (isset($data['request'])) { + $request = $data['request']; + + $output['responseStatus'] = $request['status_code']; + } + + if (isset($data['queries'])) { + $queries = $data['queries']; + foreach($queries['statements'] as $statement){ + $output['databaseQueries'][] = [ + 'query' => $statement['sql'], + 'bindings' => $statement['params'], + 'time' => $statement['duration'] * 1000, + 'connection' => $statement['connection'] + ]; + } + + $output['databaseDuration'] = $queries['accumulated_duration'] * 1000; + + } + + return $output; + } + + protected function unvar_dump($str) { + $str = str_replace($str, '\n', "\n"); + if (strpos($str, "\n") === false) { + //Add new lines: + $regex = array( + '#(\\[.*?\\]=>)#', + '#(string\\(|int\\(|float\\(|array\\(|NULL|object\\(|})#', + ); + $str = preg_replace($regex, "\n\\1", $str); + $str = trim($str); + } + $regex = array( + '#^\\040*NULL\\040*$#m', + '#^\\s*array\\((.*?)\\)\\s*{\\s*$#m', + '#^\\s*string\\((.*?)\\)\\s*(.*?)$#m', + '#^\\s*int\\((.*?)\\)\\s*$#m', + '#^\\s*bool\\(true\\)\\s*$#m', + '#^\\s*bool\\(false\\)\\s*$#m', + '#^\\s*float\\((.*?)\\)\\s*$#m', + '#^\\s*\[(\\d+)\\]\\s*=>\\s*$#m', + '#\\s*?\\r?\\n\\s*#m', + ); + $replace = array( + 'N', + 'a:\\1:{', + 's:\\1:\\2', + 'i:\\1', + 'b:1', + 'b:0', + 'd:\\1', + 'i:\\1', + ';' + ); + $serialized = preg_replace($regex, $replace, $str); + $func = create_function( + '$match', + 'return "s:".strlen($match[1]).":\\"".$match[1]."\\"";' + ); + $serialized = preg_replace_callback( + '#\\s*\\["(.*?)"\\]\\s*=>#', + $func, + $serialized + ); + $func = create_function( + '$match', + 'return "O:".strlen($match[1]).":\\"".$match[1]."\\":".$match[2].":{";' + ); + $serialized = preg_replace_callback( + '#object\\((.*?)\\).*?\\((\\d+)\\)\\s*{\\s*;#', + $func, + $serialized + ); + $serialized = preg_replace( + array('#};#', '#{;#'), + array('}', '{'), + $serialized + ); + + return unserialize($serialized); + } +} diff --git a/src/Support/Clockwork/Middleware.php b/src/Support/Clockwork/Middleware.php new file mode 100644 index 00000000..b1c8c5ad --- /dev/null +++ b/src/Support/Clockwork/Middleware.php @@ -0,0 +1,69 @@ +app = $app; + $this->exceptionHandler = $exceptionHandler; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */ + $debugbar = $this->app['debugbar']; + + try { + /** @var \Illuminate\Http\Response $response */ + $response = $next($request); + } catch (\Exception $e) { + $debugbar->addException($e); + + $this->exceptionHandler->report($e); + $response = $this->exceptionHandler->render($request, $e); + } + + if ($request->is('_debugbar*') || $request->is('*clockwork*')) { + return $response; + } + + $response->headers->set('X-Clockwork-Id', $debugbar->getCurrentRequestId(), true); + $response->headers->set('X-Clockwork-Version', 1, true); + $response->headers->set('X-Clockwork-Path','/_debugbar/clockwork/', true); + + + return $debugbar->modifyResponse($request, $response); + + } +} From e706f8299ee5aa43e727afb099d20b2f6bbe8add Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 12 Jul 2015 22:14:14 +0200 Subject: [PATCH 2/9] Tweak request/timeline --- src/Support/Clockwork/Converter.php | 77 +++++------------------------ 1 file changed, 13 insertions(+), 64 deletions(-) diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 9025c1ac..231bb986 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -36,10 +36,23 @@ public function convert($data) ]; + if (isset($data['request'])) { + $request = $data['request']; + + $output['responseStatus'] = $request['status_code']; + foreach($request as $key => $value){ + $output['headers'][$key] = [$value]; + } + } + if (isset($data['time'])) { $time = $data['time']; $output['responseTime'] = $time['end']; $output['responseDuration'] = $time['duration'] * 1000; + foreach($time['measures'] as $measure) { + $measure['duration'] = $measure['duration'] * 1000; + $output['timelineData'][] = $measure; + } } if (isset($data['route'])) { @@ -55,11 +68,7 @@ public function convert($data) $output['messages'] = $messages['messages']; } - if (isset($data['request'])) { - $request = $data['request']; - $output['responseStatus'] = $request['status_code']; - } if (isset($data['queries'])) { $queries = $data['queries']; @@ -79,64 +88,4 @@ public function convert($data) return $output; } - protected function unvar_dump($str) { - $str = str_replace($str, '\n', "\n"); - if (strpos($str, "\n") === false) { - //Add new lines: - $regex = array( - '#(\\[.*?\\]=>)#', - '#(string\\(|int\\(|float\\(|array\\(|NULL|object\\(|})#', - ); - $str = preg_replace($regex, "\n\\1", $str); - $str = trim($str); - } - $regex = array( - '#^\\040*NULL\\040*$#m', - '#^\\s*array\\((.*?)\\)\\s*{\\s*$#m', - '#^\\s*string\\((.*?)\\)\\s*(.*?)$#m', - '#^\\s*int\\((.*?)\\)\\s*$#m', - '#^\\s*bool\\(true\\)\\s*$#m', - '#^\\s*bool\\(false\\)\\s*$#m', - '#^\\s*float\\((.*?)\\)\\s*$#m', - '#^\\s*\[(\\d+)\\]\\s*=>\\s*$#m', - '#\\s*?\\r?\\n\\s*#m', - ); - $replace = array( - 'N', - 'a:\\1:{', - 's:\\1:\\2', - 'i:\\1', - 'b:1', - 'b:0', - 'd:\\1', - 'i:\\1', - ';' - ); - $serialized = preg_replace($regex, $replace, $str); - $func = create_function( - '$match', - 'return "s:".strlen($match[1]).":\\"".$match[1]."\\"";' - ); - $serialized = preg_replace_callback( - '#\\s*\\["(.*?)"\\]\\s*=>#', - $func, - $serialized - ); - $func = create_function( - '$match', - 'return "O:".strlen($match[1]).":\\"".$match[1]."\\":".$match[2].":{";' - ); - $serialized = preg_replace_callback( - '#object\\((.*?)\\).*?\\((\\d+)\\)\\s*{\\s*;#', - $func, - $serialized - ); - $serialized = preg_replace( - array('#};#', '#{;#'), - array('}', '{'), - $serialized - ); - - return unserialize($serialized); - } } From a524a01a0f7b9317365e0503380d6bacfbb98694 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 10:25:07 +0200 Subject: [PATCH 3/9] Change adding headers --- src/LaravelDebugbar.php | 11 +++++ src/ServiceProvider.php | 5 -- src/Support/Clockwork/Middleware.php | 69 ---------------------------- 3 files changed, 11 insertions(+), 74 deletions(-) delete mode 100644 src/Support/Clockwork/Middleware.php diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index af3285d3..683914aa 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -545,6 +545,10 @@ public function modifyResponse($request, $response) } } + if ($app['config']->get('debugbar.clockwork')) { + $this->addClockworkHeaders($response); + } + // Stop further rendering (on subrequests etc) $this->disable(); @@ -821,4 +825,11 @@ protected function selectStorage(DebugBar $debugbar) $debugbar->setStorage($storage); } } + + protected function addClockworkHeaders($response) + { + $response->headers->set('X-Clockwork-Id', $this->getCurrentRequestId(), true); + $response->headers->set('X-Clockwork-Version', 1, true); + $response->headers->set('X-Clockwork-Path','/_debugbar/clockwork/', true); + } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 04765986..77ab118f 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -107,11 +107,6 @@ public function boot() $debugbar->boot(); $kernel = $this->app['Illuminate\Contracts\Http\Kernel']; - - if ($this->app['config']->get('debugbar.clockwork')) { - $kernel->pushMiddleware('Barryvdh\Debugbar\Support\Clockwork\Middleware'); - } - $kernel->pushMiddleware('Barryvdh\Debugbar\Middleware\Debugbar'); } diff --git a/src/Support/Clockwork/Middleware.php b/src/Support/Clockwork/Middleware.php deleted file mode 100644 index b1c8c5ad..00000000 --- a/src/Support/Clockwork/Middleware.php +++ /dev/null @@ -1,69 +0,0 @@ -app = $app; - $this->exceptionHandler = $exceptionHandler; - } - - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed - */ - public function handle($request, Closure $next) - { - /** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */ - $debugbar = $this->app['debugbar']; - - try { - /** @var \Illuminate\Http\Response $response */ - $response = $next($request); - } catch (\Exception $e) { - $debugbar->addException($e); - - $this->exceptionHandler->report($e); - $response = $this->exceptionHandler->render($request, $e); - } - - if ($request->is('_debugbar*') || $request->is('*clockwork*')) { - return $response; - } - - $response->headers->set('X-Clockwork-Id', $debugbar->getCurrentRequestId(), true); - $response->headers->set('X-Clockwork-Version', 1, true); - $response->headers->set('X-Clockwork-Path','/_debugbar/clockwork/', true); - - - return $debugbar->modifyResponse($request, $response); - - } -} From 1a01fb8a366defcb2c9bfa89ea84afea974ebbf1 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 10:25:30 +0200 Subject: [PATCH 4/9] Fix timeline, messages, route, session --- src/Support/Clockwork/Converter.php | 62 ++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 231bb986..52dcbdc0 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -22,7 +22,6 @@ public function convert($data) 'cookies' => [], 'emailsData' => [], 'getData' => [], - 'headers' => [], 'log' => [], 'postData' => [], 'sessionData' => [], @@ -32,7 +31,6 @@ public function convert($data) 'responseTime' => null, 'responseStatus' => null, 'responseDuration' => 0, - 'log' => [], ]; @@ -47,29 +45,55 @@ public function convert($data) if (isset($data['time'])) { $time = $data['time']; + $output['time'] = $time['start']; $output['responseTime'] = $time['end']; $output['responseDuration'] = $time['duration'] * 1000; foreach($time['measures'] as $measure) { - $measure['duration'] = $measure['duration'] * 1000; - $output['timelineData'][] = $measure; + $output['timelineData'][] = [ + 'data' => [], + 'description' => $measure['label'], + 'duration' => $measure['duration'] * 1000, + 'end' => $measure['end'], + 'start' => $measure['start'], + 'relative_start' => $measure['start'] - $time['start'], + ]; } } if (isset($data['route'])) { $route = $data['route']; - if (isset($route['uses'])) { - $output['controller'] = $route['uses']; + $controller = null; + if (isset($route['controller'])) { + $controller = $route['controller']; + } elseif (isset($route['uses'])) { + $controller = $route['uses']; } + + $output['controller'] = $controller; + + list($method, $uri) = explode(' ', $route['uri'], 2); + + $output['routes'][] = [ + 'action' => $controller, + 'after' => isset($route['after']) ? $route['after'] : null, + 'before' => isset($route['before']) ? $route['before'] : null, + 'method' => $method, + 'name' => isset($route['as']) ? $route['as'] : null, + 'uri' => $uri, + ]; } if (isset($data['messages'])) { - $messages = $data['messages']; - $output['messages'] = $messages['messages']; + foreach($data['messages']['messages'] as $message) { + $output['log'][] = [ + 'message' => $message['message'], + 'time' => $message['time'], + 'level' => $message['label'], + ]; + } } - - if (isset($data['queries'])) { $queries = $data['queries']; foreach($queries['statements'] as $statement){ @@ -82,7 +106,25 @@ public function convert($data) } $output['databaseDuration'] = $queries['accumulated_duration'] * 1000; + } + + if (isset($data['views'])) { + foreach ($data['views']['templates'] as $view) { + $output['viewsData'][] = [ + 'description' => 'Rendering a view', + 'duration' => 0, + 'end' => 0, + 'start' => 0, + 'data' => [ + 'name' => $view['name'], + 'data' => $view['params'], + ], + ]; + } + } + if (isset($data['session'])) { + $output['sessionData'] = $data['session']; } return $output; From f6e0c4d73672b385fd5c7b653098f0f0d3ce103c Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 10:26:25 +0200 Subject: [PATCH 5/9] Add to Lumen --- src/LumenServiceProvider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php index 86cf100c..795a20b1 100644 --- a/src/LumenServiceProvider.php +++ b/src/LumenServiceProvider.php @@ -75,6 +75,11 @@ public function boot() 'uses' => 'OpenHandlerController@handle', 'as' => 'debugbar.openhandler', ]); + + $router->get('clockwork/{id?}', [ + 'uses' => 'OpenHandlerController@clockwork', + 'as' => 'debugbar.clockwork', + ]); $router->get('assets/stylesheets', [ 'uses' => 'AssetController@css', From d6da6743a3b63e359f9ce8c0002206f3ac2507de Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 10:29:55 +0200 Subject: [PATCH 6/9] Fix sql duration --- src/Support/Clockwork/Converter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 52dcbdc0..8b620b67 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -100,7 +100,7 @@ public function convert($data) $output['databaseQueries'][] = [ 'query' => $statement['sql'], 'bindings' => $statement['params'], - 'time' => $statement['duration'] * 1000, + 'duration' => $statement['duration'] * 1000, 'connection' => $statement['connection'] ]; } From 14e06bd92158040476ac77e7926b8b032fa3c5d4 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 10:47:56 +0200 Subject: [PATCH 7/9] Fix routes --- src/LumenServiceProvider.php | 2 +- src/ServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LumenServiceProvider.php b/src/LumenServiceProvider.php index 795a20b1..70d63690 100644 --- a/src/LumenServiceProvider.php +++ b/src/LumenServiceProvider.php @@ -76,7 +76,7 @@ public function boot() 'as' => 'debugbar.openhandler', ]); - $router->get('clockwork/{id?}', [ + $router->get('clockwork/{id}', [ 'uses' => 'OpenHandlerController@clockwork', 'as' => 'debugbar.clockwork', ]); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 77ab118f..1cc2e0e5 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -74,7 +74,7 @@ public function boot() 'as' => 'debugbar.openhandler', ]); - $router->get('clockwork/{id?}', [ + $router->get('clockwork/{id}', [ 'uses' => 'OpenHandlerController@clockwork', 'as' => 'debugbar.clockwork', ]); From afacec2b823179b64c187c72088be7c28b5ca785 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 15:44:24 +0200 Subject: [PATCH 8/9] Use Clockwork Collector for request/session --- src/LaravelDebugbar.php | 21 ++++- src/Support/Clockwork/ClockworkCollector.php | 91 ++++++++++++++++++++ src/Support/Clockwork/Converter.php | 14 +-- 3 files changed, 111 insertions(+), 15 deletions(-) create mode 100644 src/Support/Clockwork/ClockworkCollector.php diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 683914aa..9ba21946 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -20,6 +20,7 @@ use DebugBar\DataCollector\PhpInfoCollector; use DebugBar\DataCollector\RequestDataCollector; use DebugBar\DataCollector\TimeDataCollector; +use Barryvdh\Debugbar\Support\Clockwork\ClockworkCollector; use DebugBar\DebugBar; use DebugBar\Storage\PdoStorage; use DebugBar\Storage\RedisStorage; @@ -511,6 +512,23 @@ public function modifyResponse($request, $response) } } + if ($app['config']->get('debugbar.clockwork')) { + + try { + $this->addCollector(new ClockworkCollector($request, $response, $sessionManager)); + } catch (\Exception $e) { + $this->addException( + new Exception( + 'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(), + $e->getCode(), + $e + ) + ); + } + + $this->addClockworkHeaders($response); + } + if ($response->isRedirection()) { try { $this->stackData(); @@ -545,9 +563,6 @@ public function modifyResponse($request, $response) } } - if ($app['config']->get('debugbar.clockwork')) { - $this->addClockworkHeaders($response); - } // Stop further rendering (on subrequests etc) $this->disable(); diff --git a/src/Support/Clockwork/ClockworkCollector.php b/src/Support/Clockwork/ClockworkCollector.php new file mode 100644 index 00000000..3c421c19 --- /dev/null +++ b/src/Support/Clockwork/ClockworkCollector.php @@ -0,0 +1,91 @@ + + * + */ +class ClockworkCollector 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 'clockwork'; + } + + /** + * {@inheritDoc} + */ + public function getWidgets() + { + return null; + } + + /** + * {@inheritdoc} + */ + public function collect() + { + $request = $this->request; + $response = $this->response; + + $data = array( + 'getData' => $request->query->all(), + 'postData' => $request->request->all(), + 'headers' => $request->headers->all(), + 'cookies' => $request->cookies->all(), + 'uri' => $request->getRequestUri(), + 'method' => $request->getMethod(), + 'responseStatus' => $response->getStatusCode(), + ); + + if ($this->session) { + $sessionAttributes = array(); + foreach ($this->session->all() as $key => $value) { + $sessionAttributes[$key] = $value; + } + $data['sessionData'] = $sessionAttributes; + } + + if (isset($data['postData']['php-auth-pw'])) { + $data['postData']['php-auth-pw'] = '******'; + } + + if (isset($data['postData']['PHP_AUTH_PW'])) { + $data['postData']['PHP_AUTH_PW'] = '******'; + } + + return $data; + } + +} diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 8b620b67..a3c651b6 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -33,14 +33,8 @@ public function convert($data) 'responseDuration' => 0, ]; - - if (isset($data['request'])) { - $request = $data['request']; - - $output['responseStatus'] = $request['status_code']; - foreach($request as $key => $value){ - $output['headers'][$key] = [$value]; - } + if (isset($data['clockwork'])) { + $output = array_merge($output, $data['clockwork']); } if (isset($data['time'])) { @@ -123,10 +117,6 @@ public function convert($data) } } - if (isset($data['session'])) { - $output['sessionData'] = $data['session']; - } - return $output; } From f3a1a2b7b54f9a0c58ed3e44425fbecf0975b3e1 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 13 Jul 2015 15:45:18 +0200 Subject: [PATCH 9/9] Add mails --- src/Support/Clockwork/Converter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index a3c651b6..e6473d97 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -117,6 +117,18 @@ public function convert($data) } } + if (isset($data['swiftmailer_mails'])) { + foreach($data['swiftmailer_mails']['mails'] as $mail) { + $output['emailsData'][] = [ + 'data' => [ + 'to' => $mail['to'], + 'subject' => $mail['subject'], + 'headers' => isset($mail['headers']) ? explode("\n", $mail['headers']) : null, + ], + ]; + } + } + return $output; }