2017 © Pedro Peláez
 

library slim-phpconsole

PHP-Console logging support for Slim Framework

image

amenadiel/slim-phpconsole

PHP-Console logging support for Slim Framework

  • Friday, March 11, 2016
  • by amenadiel
  • Repository
  • 11 Watchers
  • 9 Stars
  • 450 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

SlimPHPConsole

PHP-Console log writer for Slim Framework, (*1)

Packagist, (*2)

Use this custom log writer to output Slim Framework's log messages to your browser's console using PHP-Console., (*3)

Installation

Just add amenadiel/slim-phpconsole to your composer.json file in the require or require-dev sections:, (*4)

{
    "require": {
        "amenadiel/slim-phpconsole":"~0.0.4"
    }
}

Usage

Instantiate the log writer. If you don't want to have the handler autostarted, pass false as a parameter, true is implied otherwise., (*5)

When the handler is started it will set itself as error and exception handler too, unless you set it otherwise., (*6)

    $logwriter = new \Amenadiel\SlimPHPConsole\PHPConsoleWriter(true);

    $app = new \Slim\Slim(array(
        'log.enabled' => true,
        'log.level' => \Slim\Log::DEBUG,
        'log.writer' => $logwriter
    ));

Starting from version 0.0.6 this adapter extends Slim\Middleware. Therefore, you can also use the add method of your app, (*7)

    $app = new \Slim\Slim(array(
        'log.enabled' => true,
        'log.level' => \Slim\Log::DEBUG
    ));

    $app->add(new \Amenadiel\SlimPHPConsole\PHPConsoleWriter);

Both ways of setting PHP-Console as your logger are pretty much the same. Afterwards, you can send messages to your browser's console using $app->log's methods., (*8)

    $app->log->debug('Debug called!');
    $app->log->info('This is just info');
    $app->log->warning('Heads Up! This is a warning');

You can pass custom tags to PHPConsole by using this adapter's debug method which forwards its parameters to PHPConsole's debug method., (*9)

    $app->log->getWriter()->debug('This has a custom tag', 'custom.tag');

If you are using PHPConsole directly somewhere else in your app, remember not to start it twice, for it will throw an exception. Use its isStarted method to check if it's already started., (*10)

    $myHandler = \PhpConsole\Handler::getInstance();

    if (!$myHandler->isStarted()) {
        $myHandler->start(); // Only start it if it hasn't been started yet
    }

Optional Settings

You can use PHP-Console's configuration methods by getting a reference to the Handler instance or the Connector instance. For example:, (*11)

```php $logwriter = new \Amenadiel\SlimPHPConsole\PHPConsoleWriter(false); $handler = $logwriter->getHandler(); $handler->setHandleErrors(false); // disable errors handling, must be done before 'start' method $handler->start();, (*12)

$connector = $logwriter->getConnector();
$connector->setPassword('macoy123'); //sets a very insecure passwd

```, (*13)

The Versions

11/03 2016

dev-master

9999999-dev http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

11/03 2016

0.1.1

0.1.1.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

11/03 2016

0.1.0

0.1.0.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

28/10 2015

v0.0.7

0.0.7.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

06/07 2015

v0.0.6

0.0.6.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

03/07 2015

v0.0.5

0.0.5.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

03/07 2015

v0.0.4

0.0.4.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

03/07 2015

0.0.3

0.0.3.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

03/07 2015

v0.0.2

0.0.2.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging

03/07 2015

v0.0.1

0.0.1.0 http://github.com/amenadiel/SlimPHPConsole

PHP-Console logging support for Slim Framework

  Sources   Download

MIT

The Requires

 

middleware extensions logging