承接 shahghasiadil/laravel-env-validator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

shahghasiadil/laravel-env-validator

最新稳定版本:v1.0.2

Composer 安装命令:

composer require shahghasiadil/laravel-env-validator

包简介

A Laravel package to validate environments variables configuration values and generate environments variables rules.

README 文档

README

The laravel-env-validator package provides a way to validate your .env configuration values in a Laravel application.

Installation

  1. Install via Composer:

    composer require shahghasiadil/laravel-env-validator
  2. Publish the Configuration:

    php artisan vendor:publish --tag=config --provider="LaravelEnvValidator\LaravelEnvValidatorServiceProvider"

Usage

  1. Generating Validation Rules from .env:

    To generate validation rules based on your .env values:

    php artisan env:generate-rules

    This will read your .env file, generate validation rules, and store them in config/env-validator.php.

  2. Checking Env Validity:

    To validate your current environment based on the generated rules:

    php artisan env:vaildate
  3. Middleware:

    Ensure your environment is valid on every request by adding the middleware:

    protected $middlewareAliases = [
        'ensureValidEnv' => \LaravelEnvValidator\Middlewares\EnsureValidEnv::class,
    ];

    Add this to your app/Http/Kernel.php.

     Route::middleware('ensureValidEnv')->group(function () {
         // ... code
     });
    

    Add middleware to your routes/web.php

  4. Customize Validation Rules:

    To add or modify validation rules, edit the config/env-validator.php.

Configuration

All configuration for this package is stored in the env-validator.php config file. It contains an array of validation rules corresponding to each key in your .env file.

Changelog

For a detailed changelog, see the CHANGELOG.

Configs

If env changes aren't working please run the following command:

php artisan config:clear

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-04