定制 mylonia/site-guard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mylonia/site-guard

Composer 安装命令:

composer require mylonia/site-guard

包简介

Guard your website from visitors by requiring a password.

README 文档

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:

A simple password prompt.

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.

统计信息

  • 总下载量: 67
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固