PHPackages                             naqla/laravel-performance-lock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. naqla/laravel-performance-lock

ActiveLibrary[Payment Processing](/categories/payments)

naqla/laravel-performance-lock
==============================

Lock your Laravel website until client payment

v2.0.0(5mo ago)018↓100%MITPHPPHP ^8.2|^8.3

Since Oct 6Pushed 5mo agoCompare

[ Source](https://github.com/ayoub-laaouaoucha/laravel-performance-lock)[ Packagist](https://packagist.org/packages/naqla/laravel-performance-lock)[ RSS](/packages/naqla-laravel-performance-lock/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (0)

Laravel Performance Lock 🔒
==========================

[](#laravel-performance-lock-)

[![Latest Version](https://camo.githubusercontent.com/35e1f63f5d8e0ed72d0b126942721a044bae7abb1bed06ef5d7bbc1cd9c7f4d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e61716c612f6c61726176656c2d706572666f726d616e63652d6c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/naqla/laravel-performance-lock)[![Total Downloads](https://camo.githubusercontent.com/1ecd21abf36d039750ede3de89a5f36cee718ed0fa347389480c85c4e124e95c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e61716c612f6c61726176656c2d706572666f726d616e63652d6c6f636b2e7376673f7374796c653d666c61742d737175617265266361636865427573743d31)](https://packagist.org/packages/naqla/laravel-performance-lock)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A simple and elegant Laravel package that allows you to lock your entire website until client payment or any other condition is met. Perfect for freelancers and agencies who want to ensure payment before delivering the final product.

Features
--------

[](#features)

- 🔐 **Lock/Unlock entire website** with a single command
- 🎨 **Customizable lock page** with your own views
- 🔑 **Secret unlock URL** for secure access
- ⚡ **Easy toggle** via routes or programmatically
- 🎯 **Middleware-based** protection
- 📝 **Configurable messages** and titles
- 🚀 **Zero dependencies** (uses only Laravel core)
- 🔒 **Hidden lock mechanism** - no .env pollution
- 📊 **Lock metadata tracking** - track when and who locked the site

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11.x or 12.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require naqla/laravel-performance-lock
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=performance-lock-config
```

This will create a `config/performance-lock.php` file where you can customize the lock message and title.

### Publish Views (Optional)

[](#publish-views-optional)

If you want to customize the lock page view:

```
php artisan vendor:publish --tag=performance-lock-views
```

This will publish the views to `resources/views/vendor/performance-lock/locked.blade.php`.

Configuration
-------------

[](#configuration)

Add these variables to your `.env` file (optional):

```
SITE_LOCK_TITLE="Site Locked"
SITE_LOCK_MESSAGE="This site is locked until payment is received."
SITE_UNLOCK_CODE="show-me-the-money"
```

Usage
-----

[](#usage)

### 1. Apply Middleware

[](#1-apply-middleware)

Apply the middleware to your routes that you want to protect:

#### Protect All Routes

[](#protect-all-routes)

In `bootstrap/app.php` (Laravel 11+):

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Naqla\PerformanceLock\Http\Middleware\PerformanceLockMiddleware::class,
    ]);
})
```

Or in `app/Http/Kernel.php` (Laravel 10):

```
protected $middlewareGroups = [
    'web' => [
        // ... other middleware
        \Naqla\PerformanceLock\Http\Middleware\PerformanceLockMiddleware::class,
    ],
];
```

#### Protect Specific Routes

[](#protect-specific-routes)

```
Route::middleware(['performance-lock'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
    Route::get('/profile', [ProfileController::class, 'show']);
});
```

### 2. Lock/Unlock Methods

[](#2-lockunlock-methods)

#### Using Built-in Routes

[](#using-built-in-routes)

**Lock the site:**

```
https://yourdomain.com/lock

```

**Unlock the site (with secret code):**

```
https://yourdomain.com/unlock/show-me-the-money

```

> ⚠️ **Important:** Change the secret code in your `.env` file:
>
> ```
> SITE_UNLOCK_CODE="your-secret-code-here"
> ```

#### Programmatically

[](#programmatically)

```
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"
```

#### Using API Endpoint

[](#using-api-endpoint)

```
# Lock the site
curl -X POST https://yourdomain.com/performance-lock/toggle \
  -H "Content-Type: application/json" \
  -d '{"state": "lock"}'

# Unlock the site
curl -X POST https://yourdomain.com/performance-lock/toggle \
  -H "Content-Type: application/json" \
  -d '{"state": "unlock"}'

# Toggle current state
curl -X POST https://yourdomain.com/performance-lock/toggle
```

### 3. Artisan Commands (Optional)

[](#3-artisan-commands-optional)

Create custom Artisan commands for easier management:

```
// 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! 🔒');
    }
}
```

```
php artisan site:lock
php artisan site:unlock
```

Customization
-------------

[](#customization)

### Custom Lock Page

[](#custom-lock-page)

After publishing the views, edit `resources/views/vendor/performance-lock/locked.blade.php`:

```

    {{ config('performance-lock.lock_title') }}

        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            text-align: center;
            color: white;
        }
        .lock-icon {
            font-size: 80px;
            margin-bottom: 20px;
        }
        h1 {
            font-size: 2.5em;
            margin-bottom: 20px;
        }
        p {
            font-size: 1.2em;
        }

        🔒
        {{ config('performance-lock.lock_title') }}
        {{ config('performance-lock.lock_message') }}

```

### Change Secret Code

[](#change-secret-code)

Add your secret code to `.env`:

```
SITE_UNLOCK_CODE="your-super-secret-code-here"
```

Or update `config/performance-lock.php`:

```
'unlock_code' => env('SITE_UNLOCK_CODE', 'show-me-the-money'),
```

### Custom Routes

[](#custom-routes)

You can disable the default routes by not loading them, and create your own:

```
// In your routes/web.php
Route::middleware(['auth', 'admin'])->group(function () {
    Route::post('/admin/site/lock', function() {
        \Naqla\PerformanceLock\PerformanceLock::lock();
        return back()->with('success', 'Site locked!');
    });

    Route::post('/admin/site/unlock', function() {
        \Naqla\PerformanceLock\PerformanceLock::unlock();
        return back()->with('success', 'Site unlocked!');
    });
});
```

Use Cases
---------

[](#use-cases)

- **Freelance Projects:** Lock the site until the client makes the final payment
- **Agency Work:** Ensure milestone payments before deployment
- **Maintenance Mode:** Different from Laravel's maintenance mode, allows specific unlock mechanisms
- **Demo Sites:** Lock after trial period expires
- **Staging Environments:** Restrict access to staging sites

How It Works
------------

[](#how-it-works)

1. The package creates a hidden `.lock` file in the vendor directory when locked
2. Middleware checks for this file on each request
3. If locked, users see a custom lock page (403 response)
4. The unlock route bypasses the middleware
5. Lock state persists even after deployment or server restart
6. Lock metadata (timestamp, IP, user agent) is tracked automatically

### Why Hidden File Instead of .env?

[](#why-hidden-file-instead-of-env)

- ✅ **No .env pollution** - Your main project stays clean
- ✅ **Persistent** - Survives composer updates
- ✅ **Fast** - Simple file existence check
- ✅ **Hidden** - Stored in `vendor/naqla/laravel-performance-lock/.lock`
- ✅ **Metadata tracking** - Know when and who locked the site

Security Considerations
-----------------------

[](#security-considerations)

- Always use a strong, unique secret code for the unlock URL
- Consider adding additional authentication to lock/unlock routes in production
- The `/lock` route is public by default - protect it if needed: ```
    Route::middleware(['auth'])->get('/lock', function() {
        \Naqla\PerformanceLock\PerformanceLock::lock();
        return redirect('/')->with('status', 'Site has been locked 🔒');
    });
    ```
- Don't share your unlock URL publicly
- Change the default unlock code before deploying to production

Testing
-------

[](#testing)

The package automatically bypasses the lock for the toggle routes, allowing you to always access the unlock functionality.

API Reference
-------------

[](#api-reference)

### Available Methods

[](#available-methods)

```
// 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
```

Troubleshooting
---------------

[](#troubleshooting)

### Site still accessible after locking

[](#site-still-accessible-after-locking)

Make sure the middleware is properly registered and applied to your routes.

### Can't unlock the site

[](#cant-unlock-the-site)

- Check that your unlock code matches the one in `.env` or config
- Ensure the unlock route is not protected by the middleware
- Try accessing `/unlock/your-secret-code` directly

### Lock state not persisting

[](#lock-state-not-persisting)

- Ensure the vendor directory is writable
- Check file permissions on the package directory

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Credits
-------

[](#credits)

- [AYOUB LAAOUAOUCHA](https://github.com/naqla)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Support
-------

[](#support)

If you find this package helpful, please consider:

- ⭐ Starring the repository
- 🐛 Reporting issues
- 📖 Improving documentation
- 🔀 Contributing code

---

Made with ❤️ by [AYOUB LAAOUAOUCHA](mailto:laaouaoucha333@gmail.com)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance70

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

6

Last Release

176d ago

Major Versions

v1.1.2 → v2.0.02025-11-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/b86465e32fee7cd67b681692d5853cb27559f87ff85b79fc136145be7afae4cb?d=identicon)[AYOUB LAAOUAOUCHA](/maintainers/AYOUB%20LAAOUAOUCHA)

---

Top Contributors

[![ayoub-laaouaoucha](https://avatars.githubusercontent.com/u/76959201?v=4)](https://github.com/ayoub-laaouaoucha "ayoub-laaouaoucha (12 commits)")

---

Tags

middlewarelaravelperformancepaymentlockfreelance

### Embed Badge

![Health badge](/badges/naqla-laravel-performance-lock/health.svg)

```
[![Health](https://phpackages.com/badges/naqla-laravel-performance-lock/health.svg)](https://phpackages.com/packages/naqla-laravel-performance-lock)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[henryejemuta/laravel-monnify

A laravel package to seamlessly integrate monnify api within your laravel application

132.1k](/packages/henryejemuta-laravel-monnify)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
