PHP code example of naqla / laravel-performance-lock
1. Go to this page and download the library: Download naqla/laravel-performance-lock 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/ */
use Naqla\PerformanceLock\PerformanceLock;
// Lock the site
PerformanceLock::lock();
// Unlock the site
PerformanceLock::unlock();
// Toggle lock state
PerformanceLock::toggle();
// Check if site is locked
if (PerformanceLock::isLocked()) {
// Site is locked
}
// Get lock information
$info = PerformanceLock::getLockInfo();
// Returns: ['locked' => true, 'locked_at' => '2025-10-06 15:30:45', 'locked_by_ip' => '192.168.1.1', ...]
// Get how long the site has been locked
$duration = PerformanceLock::getLockedDuration();
// Returns: "2 hours ago"
// app/Console/Commands/LockSite.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Naqla\PerformanceLock\PerformanceLock;
class LockSite extends Command
{
protected $signature = 'site:lock';
protected $description = 'Lock the website';
public function handle()
{
PerformanceLock::lock();
$this->info('Site has been locked! 🔒');
}
}
Route::middleware(['auth'])->get('/lock', function() {
\Naqla\PerformanceLock\PerformanceLock::lock();
return redirect('/')->with('status', 'Site has been locked 🔒');
});
// Check if site is locked
PerformanceLock::isLocked(): bool
// Lock the site
PerformanceLock::lock(): void
// Unlock the site
PerformanceLock::unlock(): void
// Toggle lock state
PerformanceLock::toggle(): void
// Get lock information
PerformanceLock::getLockInfo(): ?array
// Get locked duration
PerformanceLock::getLockedDuration(): ?string