Download the PHP package clue/confgen without Composer

On this page you can find all versions of the php package clue/confgen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package confgen

clue/confgen

Build Status installs on Packagist

Configuration file generator (confgen) – an easy way to generate structured (configuration) files on the fly by processing a Twig template and an arbitrary input data structure.

Table of contents

Input data

This project is all about transforming your input data structure.

As such, it makes no assumptions as to what kind of input data you're dealing with, as long as it can be expressed in a simple JSON structure. This project focuses on JSON input data for a few key reasons:

Chances are, your input data might already be in a JSON file. If it's not, then it's very easy to either convert with one of the many existing tools or libraries or use some code similar to the following example:

The structure of your input data file is entirely left up to you. This library allows you to use any arbitrary input data structure. For the following examples, this document assumes the following (totally arbitrary) input data structure:

Templates

Each (configuration) template file is essentially a plaintext (output) configuration file with some placeholders.

The template file uses the Twig template language and can hence take full advantage of its variable substitution and advanced template control logic.

In its most simple form, an arbitrary template would look something like this:

The input variables will be accessible under the data key.

You can generate the output (configuration) file by invoking confgen like this:

In this example, it will write the resulting file to the template file name without extension (i.e. template).

With the above example template and input data, the resulting output (configuration) file will look something like this:

Meta variables

Optionally, you can prefix the template file contents with the meta-data in the form of a YAML front matter. This syntax is quite simple and is pretty common for template processors and static site generators such as Jekyll.

This means that if you want to include meta-data variables, then each section starts with a three-hyphen divider (---), so that a full file would look something like this:

Documented variables:

You can also pass arbitrary custom meta-data. See meta-data schema for more details.

The meta variables will be accessible under the meta key in the Twig template. If no meta-data variables are present, then this key defaults to an empty array.

You can generate the output (configuration) file by invoking confgen like this:

If the template meta-data contains a target key, it will write the resulting file to this location.

In the above example, this means the following actions will be performed:

Sometimes it is useful to skip the execution of the scripts/commands defined by the meta variable reload. To do so you can use the optional parameter --no-scripts like this:

Configuration

You can either parse/process individual template files or use a configuration definition that allows you to process a number of files in one go.

In its most simple form, a JSON configuration structure looks like this:

Documented variables:

See configuration schema for more details.

You can generate the output (configuration) files by invoking confgen like this:

This works similar to invoking with individual template files.

Bin Usage

Once installed, you can use this tool as a bin(ary) executable.

Some usage examples are given above.

If you want to see the usage help, simply invoke its help by calling like this:

If you have installed this via $ composer require, then you may have to invoke it like this:

Lib Usage

See the above section for bin usage which is usually easier to get started.

If you want to integrate this into another tool, you may also use this project as a lib(rary). The same also applies if you want to use custom twig extensions, functions or filters.

Factory

The Factory class is a helper class that can be used to easily create a new Confgen instance.

Twig_Environment

Internally, the Factory will create a Twig_Environment instance that will be used to process the template files.

You may want to explicitly pass an instance if you want to use any of the following:

createConfgen()

The createConfgen() method can be used to create a new Confgen instance. Usually, there should be no need to call this more than once.

Confgen

The Confgen class is responsible for processing the templates (this is where the magic happens).

processTemplate

The processTemplate($templateFile, $dataFile) method can be used to generate a output (configuration) file from the given template file.

The processTemplate($templateFile, $dataFile) method throws a RuntimeException when a reload command fail. See also Meta variables section for more details on reload.

See also templates section above for more details on the The input data.

processDefinition

The processDefinition($definitionFile, $dataFile) method can be used to generate any number of output (configuration) files from the given configuration file.

The processDefinition($definitionFile, $dataFile) method throws a RuntimeException when a reload command fail. See also Meta variables section for more details on reload.

See also configuration section above for more details.

Install

You can simply download a pre-compiled and ready-to-use version as a Phar to any directory. Simply download the latest confgen.phar file from our releases page:

Latest release

That's it already. You can now verify everything works by running this:

Alternatively, you can also use this project as a library to integrate this into an existing application. The recommended way to install this library is through Composer. New to Composer?

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 7+. It's highly recommended to use PHP 7+ for this project.

If you want to create the above confgen.phar locally, you have to clone this repository and run composer build.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

To run the test suite, go to the project root and run:

License

MIT


All versions of confgen with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
twig/twig Version ~1.14
kzykhys/yaml-front-matter Version ~1.0
justinrainbow/json-schema Version ~1.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package clue/confgen contains the following files

Loading the files please wait ....