Skip to content

Repository files navigation

Hatch

PHP from PackagistLatest VersionTotal DownloadsGitHub Workflow StatusPHPStanLicense

Simple code generation tools

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

Get news and updates on the DecodeLabs blog.


Installation

This package requires PHP 8.4 or higher.

Install via Composer:

composer require decodelabs/hatch

Usage

Static arrays

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

useDecodeLabs\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

Stars

0 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages