decodelabs / hatch
Simple code generation tools
v0.1.0
2025-03-10 12:27 UTC
Requires
- php: ^8.4
- decodelabs/exceptional: ^0.5.3
Requires (Dev)
- decodelabs/phpstan-decodelabs: ^0.7.0
This package is auto-updated.
Last update: 2025-03-10 16:38:19 UTC
README
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.