PHP code example of brandworks / querylogger

1. Go to this page and download the library: Download brandworks/querylogger 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/ */

    

brandworks / querylogger example snippets


    # Add `Brandworks\Querylogger\QueryloggerServiceProvider` to the `providers` array
    'providers' => array(
        ...
        'Brandworks\Querylogger\QueryloggerServiceProvider',
    )

    # You do not need to add the alias - This is being handled for you in the service provider
    

    # file: app/config/packages/brandworks/querylogger/config.php
    'store_serialized' => false,
    'add_route' => false,
    

    # file: app/config/packages/brandworks/querylogger/config.php
    'route' => 'queries',
    

//this does not affect user load since this is done in app finish (the client did already receive response)
App::finish(function($request, $response) {
    //make sure the package is enabled -- prevent errors
    if(class_exists("QueryLogger")) {
        $queryLog = QueryLogger::getLog();

        Log::info('The query log', $queryLog);
        //or do some other stuff with the log so you can make it more readale/filter on query time/...
    }
}
shell
    $ php artisan config:publish brandworks/querylogger