pana1990/php-web-profiler

Web profiler in the browser for php application

v0.3.2-alpha 2023-03-24 07:40 UTC

README

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.