1. Go to this page and download the library: Download juanparati/query-timeout 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/ */
juanparati / query-timeout example snippets
\QueryTimeout::run(
fn() => \DB::select('SELECT SLEEP(4)'), // Your query comes here (Use pg_sleep for testing with PostgreSQL)
3 , // Interrupt if a query takes more than 3 seconds (Keep null for default timeout)
'myconnection' // Database connection (Keep null for the default connection)
fn() => logs()->error('Timeout here') // Run this callback before throwing QueryTimeoutException
);