Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Site Guard Laravel Package

mylonia/site-guard

View on GitHub
Deep Wiki
Context7

Site Guard

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor