PHP code example of pana1990 / php-web-profiler
1. Go to this page and download the library: Download pana1990/php-web-profiler library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pana1990 / php-web-profiler example snippets
$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();