2017 © Pedro PelĂĄez
 

library ldt

Debug Tools for Laravel

image

dpodsiadlo/ldt

Debug Tools for Laravel

  • Wednesday, January 11, 2017
  • by Daniel PodsiadƂo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

LDT - Debug Tools for Laravel

A package that extends Monolog and throws debug data to an external debugger., (*1)

Installation

Via Composer, (*2)

``` bash $ composer require dpodsiadlo/ldt, (*3)


### Configuration Once installed, register Laravel service provider, in your `config/app.php`: ```php 'providers' => [ ... DPodsiadlo\LDT\Providers\LDTServiceProvider::class, ]

Also register a middleware for logging requests and responses, in your app/Http/Kernel.php:, (*4)

protected $middleware = [
    ...
    \DPodsiadlo\LDT\Middleware\LogSender::class,        
];

You might also want to change the default (1800) port for external debugger (in .env):, (*5)

LDT_DEBUG_PORT=1801

Basic Usage

Use default Laravel Log Facade that provides access to the Monolog Writter., (*6)

use Log; //Laravel Log Facade

...

Log::emergency($error);
Log::alert($error);
Log::critical($error);
Log::error($error);
Log::warning($error);
Log::notice($error);
Log::info($error);
Log::debug($error);

Custom requests

Here is an example how to log a separate custom request with response, it might be helpful for debugging third party APIs:, (*7)

use DPodsiadlo\LDT\LDT;
use DPodsiadlo\LDT\Log\Request;
use DPodsiadlo\LDT\Log\Response;

...

$params = ["param1" => "someValue"];
$targetUrl = "https://third-party-service.com";

$context = stream_context_create([
        'http' => [
            'header' => "Accept: */*\r\nContent-Type: application/json\r\nUser-Agent: API-WRAPER/1.0\r\n",
            'method' => "POST",
            'content' => json_encode($params),
            'ignore_errors' => true
        ]
    ]);


$res = file_get_contents($targetUrl, false, $context);


if (!empty($http_response_header)) {

    $status = (int)explode(' ', $http_response_header[0])[1];

    LDT::log(new Request($targetUrl, "POST", $params), new Response($res, $status, $http_response_header]), true);
}

Custom storage

Also it's possible to store the custom log to a separate log file:, (*8)

use DPodsiadlo\LDT\LDT;
use DPodsiadlo\LDT\Log\Request;
use DPodsiadlo\LDT\Log\Response;

...

$params = ["param1" => "someValue"];
$targetUrl = "https://third-party-service.com";

$context = stream_context_create([
        'http' => [
            'header' => "Accept: */*\r\nContent-Type: application/json\r\nUser-Agent: API-WRAPER/1.0\r\n",
            'method' => "POST",
            'content' => json_encode($params),
            'ignore_errors' => true
        ]
    ]);


$res = file_get_contents($targetUrl, false, $context);


if (!empty($http_response_header)) {

    $status = (int)explode(' ', $http_response_header[0])[1];

    LDT::log(new Request($targetUrl, "POST", $params), new Response($res, $status, $http_response_header]), true, "third-party-log");
}

Log file name will be generated automatically based on $storage parameter and Laravel app.log config. By default log will be generated in single mode., (*9)

Remote debugging

You might also want to debug a remote instance of your project. To do that please use SSH client with port forwarding enabled:, (*10)

ssh me@some-server.com -R 1800:localhost:1800

External Debugger

LDT is compatible with LDT Console - Free Chrome App., (*11)

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

11/01 2017

dev-master

9999999-dev

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

09/01 2017

v1.1.1

1.1.1.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

09/01 2017

v1.1.0

1.1.0.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

05/09 2016

v1.0.4

1.0.4.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

29/06 2016

v1.0.3

1.0.3.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

29/06 2016

v1.0.2

1.0.2.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

21/06 2016

v1.0.1

1.0.1.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools

21/06 2016

v1.0.0

1.0.0.0

Debug Tools for Laravel

  Sources   Download

MIT

The Requires

 

laravel debug monolog tools