PHP code example of endeavour-agency / laravel-query-insights

1. Go to this page and download the library: Download endeavour-agency/laravel-query-insights 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/ */

    

endeavour-agency / laravel-query-insights example snippets


public function register(): void
{
    $collector = $this->app->make(QueryCollectorInterface::class);
        
    $collector
        ->registerHandler(
            $this->app->make(LogHandler::class),
        )
        ->registerHandler(
            $this->app->make(LighthouseResponseHandler::class),
        );        
}

php artisan vendor:publish --provider=EndeavourAgency\\LaravelQueryInsights\\Providers\\LaravelQueryInsightsProvider
log
[2024-11-08 14:27:30] local.INFO: Queries: POST http://localhost:8000/graphql {"queries":[{"query":"select * from `users` where `email` = '[email protected]' and `users`.`deleted_at` is null limit 1","sql":"select * from `users` where `email` = ? and `users`.`deleted_at` is null limit 1","bindings":["[email protected]"],"time":1.54}]}
[2024-11-08 14:27:31] local.INFO: Queries: POST http://localhost:8000/graphql {"queries":[{"query":"select * from `users` where `email` = '[email protected]' and `users`.`deleted_at` is null limit 1","sql":"select * from `users` where `email` = ? and `users`.`deleted_at` is null limit 1","bindings":["[email protected]"],"time":1.51}]}