mylonia / site-guard
Guard your website from visitors by requiring a password.
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Type:laravel-package
pkg:composer/mylonia/site-guard
Requires
- php: ^8.4
- laravel/framework: ^11.0|^12.0
- laravel/pint: ^1.24
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- larastan/larastan: ^3.6
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
This package is auto-updated.
Last update: 2025-10-09 14:05:40 UTC
README
Protect your site from random visitors with a simple plain-text password guard, configurable in your .env file.
Apply the middleware to your service provider of choice, and this package will prevent visiting all routes by default. Instead, a password prompt will be displayed:
It is possible to customize the password page, and to customize which routes are accessible regardless of Site Guard's activation status.
Installation
You can install the package with composer:
composer require mylonia/site-guard
Usage
Configuring a password
First, set these environment variables:
SITE_GUARD_PASSWORD=your-passphrase-here
Registering the middleware
You can register the middleware under the conditions of your liking, for example in AppServiceProvider:
use Mylonia\SiteGuard\SiteGuardMiddleware; public function boot(Router $router): void { if (! $this->app->environment('production')) { $router->pushMiddlewareToGroup('web', SiteGuardMiddleware::class); } }
This ensures that the production website is unaffected, but any potential local or staging setup will display the message. You can tweak this as desired.
Publishing assets
You can also exclude particular routes by customising the config file.
php artisan vendor:publish --provider="Mylonia\SiteGuard\SiteGuardServiceProvider"
This will publish the custom views and the site-guard config file. You can further customise the configuration file this way.
For example, you can adapt excluded_routes to exclude particular routes. By default, all site_guard.* routes are excluded, but you can add more this way. (You can use wildcards.)
You can also customise which middleware is required to run when the Site Guard routes are visited, which may be necessary depending on your project.
Testing
To run the test suite:
composer test
To run all steps (including linting, static checks, etc.) please run:
composer verify
Security Vulnerabilities
Please get in touch with info@mylonia.com to report a vulnerability.
Credits
License
The MIT License (MIT). Please see License File for more information.
