PHPackages                             ryancco/canon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. ryancco/canon

ActiveLibrary[Templating &amp; Views](/categories/templating)

ryancco/canon
=============

Generate files from templates

v0.3(3y ago)03[2 PRs](https://github.com/ryancco/canon/pulls)MITPHPPHP ^8.1

Since Dec 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ryancco/canon)[ Packagist](https://packagist.org/packages/ryancco/canon)[ Docs](https://github.com/ryancco/canon)[ RSS](/packages/ryancco-canon/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (4)Used By (0)

Generate files from templates
=============================

[](#generate-files-from-templates)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c4c526b16ad97c6a6b13c50a431adf2c6f077c9936710c9dbea660dc99bb784d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7279616e63636f2f63616e6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryancco/canon)[![Tests](https://github.com/ryancco/canon/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/ryancco/canon/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/a3b30543c92bb1cea7d6da9d7ad8e17e777e9530a5a1472fadf67b73fa921b35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7279616e63636f2f63616e6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ryancco/canon)

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](https://laravel.com/docs/9.x/blade) and the [Twig templating engine](https://twig.symfony.com/doc/3.x/templates.html). 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](https://flysystem.thephpleague.com/docs/).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require [--dev] ryancco/canon
```

Usage
-----

[](#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
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see the [Release Notes](../../releases) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Ryan Colson](https://github.com/ryancco)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1241d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e788fd955161ca75bc5d897617be45fc7997dcd1d4e6620af752e4d3acf66943?d=identicon)[ryancco](/maintainers/ryancco)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![ryancco](https://avatars.githubusercontent.com/u/20148569?v=4)](https://github.com/ryancco "ryancco (6 commits)")

---

Tags

canonryancco

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ryancco-canon/health.svg)

```
[![Health](https://phpackages.com/badges/ryancco-canon/health.svg)](https://phpackages.com/packages/ryancco-canon)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[acacha/admin-lte-template-laravel

AdminLTE template applied to Laravel Scaffolding

1.8k387.2k8](/packages/acacha-admin-lte-template-laravel)[modx/revolution

MODX Revolution is a Content Management System

1.4k9.1k12](/packages/modx-revolution)[qtism/qtism

OAT QTI-SDK

86193.8k7](/packages/qtism-qtism)[emmanuel/livewire-datatable-bs4

Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4

162.4k](/packages/emmanuel-livewire-datatable-bs4)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
