1. Go to this page and download the library: Download juanparati/laravel-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 / laravel-timeout example snippets
\DB::timeout(
3 , // Interrupt if a query takes more than 3 seconds
fn() => \DB::select('SELECT SLEEP(4)'), // Your query comes here
'myconnection' // Keep null for the default connection
);
$users = null;
\DB::timeout(
5,
fn() => $users = User::where('name', 'like', 'john%')->get()
);
foreach ($users as $user) {
if ($user->password_expiration > now()) {
... // Your application logic
}
}
\DB::timeout(
5,
function() {
$users = User::where('name', 'like', 'john%')->get()
foreach ($users as $user) {
if ($user->password_expiration > now()) {
... // Your application logic
}
}
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.