ryancco / canon
Generate files from templates
Requires
- php: ^8.1
- league/flysystem: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- illuminate/view: ^9.0
- league/flysystem-memory: ^3.0
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- twig/twig: ^3.0
Suggests
- illuminate/view: ^9.0
- twig/twig: ^3.0
This package is auto-updated.
Last update: 2024-12-09 17:57:37 UTC
README
Generate files from templates in PHP. Useful in development for templating commonly created files or files with extensive boilerplate or formatting. Leverage the full power of your preferred templating language by implementing the Ryancco\Canon\Contracts\Compiler
interface. This package includes a dependency-free, "pure PHP" implementation that supports simple variable replacement as well as an implementation for the Blade templating engine and the Twig templating engine. Each require you add the respective compiler engine to your project dependencies.
Write or read files to and from separate filesystems including local, S/FTP, AWS S3 and more by requiring any of the supported Flysystem adapters.
Installation
You can install the package via composer:
composer require [--dev] ryancco/canon
Usage
use Ryancco\Canon; $canon = new Canon($filesystem); // using a template file $canon->generate('hello-world.txt', 'filename.out', ['name' => 'World']); // using a template string $canon->generate('Hello, { name }.', 'filename.out', ['name' => 'World']);
Testing
composer test
Changelog
Please see the Release Notes for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.