matronator / mtrgen
PHP file generator engine for generating files from templates.
Fund package maintenance!
Patreon
Paypal
Ko-Fi
matronator
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.5
- matronator/parsem: ^3.0
- nette/finder: ^2.5 || ^3.0
- nette/neon: ^3.3
- nette/php-generator: ^3.0 || ^4.0
- nette/safe-stream: ^2.5 || ^3.0
- opis/json-schema: ^2.3
- symfony/console: ^6.2
- symfony/validator: ^6.2
- symfony/yaml: ^6.2
Requires (Dev)
- nette/tester: ^2.4
- dev-main
- v2.x-dev
- v2.0.0-alpha
- v1.2.1
- v1.2.0
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.1b4
- v1.1.1b3
- v1.1.1b2
- v1.1.1a
- v1.1.0
- 1.0.0
- dev-dependabot/composer/nette/safe-stream-3.0.1
- dev-dependabot/composer/symfony/yaml-6.4.0
- dev-dependabot/composer/symfony/console-6.4.0
- dev-dependabot/composer/symfony/validator-6.4.0
- dev-v1.1.1c
- dev-v1.1.1b
This package is auto-updated.
Last update: 2023-12-01 08:55:08 UTC
README
Official Website
Documentation
File generator engine that can generate PHP files from JSON/YAML/NEON templates.
Requirements
- PHP >= 7.4
- Composer
Instalation
Install with Composer:
composer require matronator/mtrgen --dev
Troubleshooting
If you get this error when trying to install:
matronator/mtrgen v1.0.0 requires composer-runtime-api ^2.2 -> found composer-runtime-api[2.1.0] but it does not match the constraint.
Run this command to update composer to the latest version:
composer self-update
If you can't or don't want to update composer, use version "^1.0"
of this package as that doesn't depend on Composer runtime API 2.2.
Documentation
Read the full documentation here.
Quickstart
You run the script from terminal using this command:
# To list all available commands
vendor/bin/mtrgen list
# To see usage of the generate command
vendor/bin/mtrgen generate --help
vendor/bin/mtrgen gen -h
# Generate from file
vendor/bin/mtrgen generate --path=my/folder/template.json
vendor/bin/mtrgen gen -p my/folder/template.json
# Generate from the global store
vendor/bin/mtrgen generate TemplateName
# Save a template to the global store
vendor/bin/mtrgen save path/to/template.json
vendor/bin/mtrgen s path/to/template.json
# Optionally provide an alias to save the template under
vendor/bin/mtrgen save path/to/template.json --alias=NewName
# Remove a template from the global store
vendor/bin/mtrgen remove TemplateName
vendor/bin/mtrgen r TemplateName
Acknowledgement
This project would not be possible without Nette's php-generator
package, which is used for the final code generation itself to output the finished PHP file.
License
MIT License
Copyright (c) 2022 Matronator
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.