melihovv / laravel-env-validator by melihovv

Laravel Validator for the .env file
35,486
15
2
Package Data
Maintainer Username: melihovv
Maintainer Contact: amelihovv@ya.ru (Alexander Melihov)
Package Create Date: 2017-01-31
Package Last Update: 2022-03-11
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-03-26 03:03:55
Package Statistics
Total Downloads: 35,486
Monthly Downloads: 230
Daily Downloads: 19
Total Stars: 15
Total Watchers: 2
Total Forks: 4
Total Open Issues: 0

Laravel Env Validator

Build Status styleci SensioLabsInsight Scrutinizer Code Quality Coverage Status

Packagist Packagist Packagist

Laravel Env Validator is meant to validate your .env file in order to avoid any unexpected behaviour for not having properly defined some variable or value.

Highlights

  • Make sure you don't go live without all required .env variables and without the correct values
  • Validate you env variables using the Laravel Validator by simple defining rules in a configuration file
  • Working in teams becomes easier

Installation

Install via composer

composer require melihovv/laravel-env-validator

Register Service Provider

Note! It is optional step if you use laravel>=5.5 with package auto discovery feature.

Add Service Provider to config/app.php in providers section

Melihovv\LaravelEnvValidator\ServiceProvider::class,

Publish configuration file

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

Example configuration file

// config/laravel-env-validator.php
<?php

return [
    'live_validation' => false,
    'rules' => [
        'SOME_IMPORTANT_VARIABLE' => 'required',
        'ANOTHER_IMPORTANT_ONE'   => 'required|in:TYPE_A,TYPE_B,TYPE_C',
    ],
];

Usage

In case you set live_validation to false in config, you may use artisan command

php artisan config:env-validator

Otherwise env variables will be validated on every application start.

Security

If you discover any security related issues, please email amelihovv@ya.ru instead of using the issue tracker.

Credits