Skip to content

pana1990/php-web-profiler

Repository files navigation

PHP Web Toolbar

Latest Stable Version Minimum PHP Version Build Status Software License

This package is under development. Please do not use in production yet 🙏

TODO

Getting Started

$ composer require --dev pana1990/php-web-profiler

Example usage with slim framework:

require __DIR__ . '/vendor/autoload.php';

$app = AppFactory::create();

// services
Db::setUp(); // setup schema
$pdoTraceable = new PdoTraceable('sqlite:' . __DIR__ . '/src/db/bbdd.db');
$log = (new Logger('log'))->pushHandler(new ErrorLogHandler());
$traceableLogger = new LoggerTraceable($log);

// setup for PhpWebProfiler
SlimPhpWebProfilerBuilder::fromApp($app)
    ->withPdo($pdoTraceable)
    ->withLogger($traceableLogger)
    ->build();

$app->get('/', function (Request $request, Response $response) use ($traceableLogger, $pdoTraceable) {
    $response->getBody()->write('Hello world!');

    $traceableLogger->error('This is an error message');

    $pdoTraceable->exec('INSERT INTO test (title) VALUES ("test");');
    $pdoTraceable->exec('SELECT * FROM test;');

    return $response;
});

$app->run();

See full example in here.

Note: with this setup you have two endpoints enabled (debug and debug/:token)

📷 Screenshots

Index page

Request panel

Request panel

Request panel

Log panel

Log panel

Database panel

Database panel

📅 ROADMAP

[ ] Add support for slim

⚖️ LICENSE

php-web-profiler is released under the MIT License. See the bundled LICENSE for details.