Skip to content

markchalloner/satisgen

Repository files navigation

SatisGen

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Introduction

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.

Installation

Via Composer

$ composer require 'markchalloner/satisgen:~1.0'

Usage

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)]

Examples

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.

htaccess

See Oban-Satis for an example .htaccess.php file.

Run

vendor/bin/satisgen .htaccess.php .htaccess

Generates a .htaccess file in the project directory.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email mark.a.r.challoner@gmail.com instead of using the issue tracker.

Notes

Built as a learning exercise with:

to pull together other techniques:

to keep a record of archived tools and techniques:

and to implement (todo):

About

Config file templating and generation

Resources

License

Stars

Watchers

Forks

Packages

No packages published