teun/laravel-environment-config-validator
最新稳定版本:v1.0.0
Composer 安装命令:
composer require teun/laravel-environment-config-validator
包简介
Validate Laravel environment variables against configurable rules.
README 文档
README
Validate Laravel environment variables against rules you define in config.
Installation
composer require teun/laravel-environment-config-validator
Publish the config file:
php artisan vendor:publish --tag=env-validator-config
Configuration
Set rules in config/env-validator.php:
return [ 'preset' => 'standard', // standard | strict | custom | your-own-preset-key 'env_file' => null, // null = runtime env, or set '.env.testing' 'presets' => [ 'standard' => [ // built-in default Laravel-oriented rules ], 'strict' => [ // built-in stricter production-focused rules ], 'my-team' => [ 'APP_ENV' => ['required', 'in:staging,production'], 'DB_PASSWORD' => ['required', 'string'], ], ], // Overrides selected preset keys. If preset=custom, this is the full ruleset. 'rules' => [ 'APP_ENV' => ['required', 'in:local,staging,production'], ], 'check_env_example' => true, ];
Usage
Run validation:
php artisan env:validate
Override preset at runtime:
php artisan env:validate --preset=strict
Validate a specific file (for example .env.testing):
php artisan env:validate --env-file=.env.testing
Machine-readable output:
php artisan env:validate --json
Fail CI when .env.example is missing required keys:
php artisan env:validate --strict-example
CI example
php artisan env:validate --strict-example
Use this command in your deployment or CI pipeline to fail early on invalid environment config.
Testing
composer test
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-16