This package checks if all the keys are available across all the .env files. This package is useful when you have multiple .env files and want to ensure 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.
- Features
- Installation
- Usage
- In Test
- Configuration
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Credits
- License
- Check if all the keys are available across all the .env files.
- Add the missing keys to the .env files automatically (configurable) considering the line numbers and empty lines.
- Check if the .env and other provided files are present in .gitignore, so that they are not committed to git by mistake.
- Sync all the available keys by line across all the .env files. Referencing the master .env file. (Configurable, default is .env)
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
--auto-add
: This option will add the missing keys to the .env files automatically.
The possible values are ask
,
auto
, and none
.
The default value is ask
.
--no-progress
: This option will disable the progress bar.
--no-display
: This option will disable all output.
php artisan env:in-git-ignore
php artisan env:sync-keys
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'],
# Master .env file to be used for syncing the keys
'master_env' => env('MASTER_ENV', '.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.