A config file generator. Allows you to seperate your configuration file and sensitive data into environment variables. Originally used to generate satis.json file from a satis.php file, but can be used as a pre-parser for any text based config files even those without a php specific file extension.
When run, will check for each environmental variables specified in the file and if found replace in the final output file or prompt the user to enter the data.
If the environmental variables are not found a Dotenv file is written at .env with the values from the user.
Via Composer
$ composer require 'markchalloner/satisgen:~1.0'
Create a satis.php file.
Within this file use the function:
$config->getConfig($name, $description, $default = null, $validator = null, $secure = false);
For example
$config->getConfig('LICENCE', 'your licence key', null, function($answer) {
if (16 !== strlen($answer)) {
throw new \RuntimeException(
'The licence should be 16 characters long'
);
}
if (1 === preg_match('/[^a-f0-9]/i', $answer)) {
throw new \RuntimeException(
'The licence should include hexadecimal characters only'
);
}
return $answer;
}, true);
Run
vendor/bin/satisgen [input_file (default:satis.php)] [output_file (default:satis.json)]
An example satis.php file can be found under
tests/fixtures/satis.php
Run
vendor/bin/satisgen vendor/markchalloner/satisgen/tests/fixtures/satis.php
Generates a satis.json file in the project directory.
See Oban-Satis for an example .htaccess.php file.
Run
vendor/bin/satisgen .htaccess.php .htaccess
Generates a .htaccess file in the project directory.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email mark.a.r.challoner@gmail.com instead of using the issue tracker.
Built as a learning exercise with:
- Symfony Console component
- Travis CI
- Packagist
- VersionEye
- SensioLabsInsight
- Scrutinizer
- The PHP League guidelines
- Shields.io
to pull together other techniques:
to keep a record of archived tools and techniques:
and to implement (todo):
- Dependecy Injection in a better way
- PHPDoc
- Twig - language independent templating