Skip to content

decodelabs/hatch

Repository files navigation

Hatch

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

Simple code generation tools

Hatch provides a set of simple tools for generating PHP code.

Get news and updates on the DecodeLabs blog.


Installation

Install via Composer:

composer require decodelabs/hatch

Usage

Static arrays

Export arrays of data for reuse as config files or static loadable datastructures.

use DecodeLabs\Hatch;

$code = Hatch::exportStaticArray([
    'foo' => 'bar',
    'baz' => 'qux',
    'quux' => [
        'corge' => 'grault',
        'garply' => 12,
        'fred' => [
            'plugh' => 'xyzzy',
            'thud' => [1, 2, 3]
        ]
    ]
]);

echo $code;

This will output:

[
    'foo' => 'bar',
    'baz' => 'qux',
    'quux' => [
        'corge' => 'grault',
        'garply' => 12,
        'fred' => [
            'plugh' => 'xyzzy',
            'thud' => [1, 2, 3]
        ]
    ]
]

Licensing

Hatch is licensed under the MIT License. See LICENSE for the full license text.

About

PHP code generation tools

Topics

Resources

License

Stars

Watchers

Forks

Languages