This package is used to check if all the keys are available across all the .env files. This package is useful when you have multiple .env files, and you want to make sure that all the keys are available across all the .env files.
With a team of developers, it is possible that some developers might forget to add the keys they used in their .env file to the .env.example file or the other way around.
You can install the package via composer:
composer require msamgan/laravel-env-keys-checker --dev
To configure this package, you can add environment variables to your .env
files. See
the config file for details. Please make sure that you refresh the config cache after
adding/updating the environment variables. php artisan config:cache
If you prefer, you can also publish the config file with:
php artisan vendor:publish --tag="env-keys-checker-config"
php artisan env:keys-check
php artisan env:in-git-ignore
You can also use this package in your test cases to make sure the required feature is working as expected.
Add the following code to your test case.
Make sure to add --auto-add=none
to override the default configuration.
it('tests that the .env key are same across all .env files.', function () {
$this->artisan('env:keys-check --auto-add=none')->assertExitCode(0);
});
Add the following code to your test case.
it('tests that the .env and other provided files are present in .gitignore.', function () {
$this->artisan('env:in-git-ignore')->assertExitCode(0);
});
You can configure the package by publishing the configuration file.
# config/env-keys-checker.php
# List of all the .env files to ignore while checking the env keys
# .env key: KEYS_CHECKER_IGNORE_FILES (coma separated string)
'ignore_files' => [],
# config/env-keys-checker.php
# List of all the .env keys to ignore while checking the env keys
# .env key: KEYS_CHECKER_IGNORE_KEYS (coma separated string)
'ignore_keys' => [],
# config/env-keys-checker.php
# strategy to add the missing keys to the .env file
# ask: will ask the user to add the missing keys
# auto: will add the missing keys automatically
# none: will not add the missing keys
# .env key: KEYS_CHECKER_AUTO_ADD (string)
'auto_add' => 'ask',
# config/env-keys-checker.php
# List of all the .env.* files to be checked if they
# are present in the .gitignore file.
# .env key: KEYS_CHECKER_GITIGNORE_FILES (coma separated string)
'gitignore_files' => ['.env'],
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.