phunkie / phunkiec
Phunkie preprocessor CLI — compiles .phunkie files into standard PHP
Package info
Type:project
pkg:composer/phunkie/phunkiec
Requires
- php: ^8.4
- md/syn: ^0.2
- symfony/console: ^7.0
- symfony/finder: ^7.0
Requires (Dev)
- phpspec/phpspec: 9.x-dev
This package is not auto-updated.
Last update: 2026-08-04 10:15:32 UTC
README
The Phunkie preprocessor. It compiles .phunkie files into standard PHP: for
comprehensions and pattern matching are desugared at compile time, so there is no
runtime cost.
Usage
phunkiec <input> --out <path> [--macro-dir <dir>]... [--macro-file <file>]...
<input>— a.phunkiefile or a directory of them.--out/-o— output file or directory (required).--macro-dir/-m— an extra directory of.synmacros (repeatable).--macro-file/-f— an extra.synmacro file (repeatable).
phunkiec src --out build
Macros
phunkiec loads macros from three places, highest precedence first (the first matching rule wins):
- Explicit — anything passed with
--macro-file/--macro-dir. - Discovered — macros shipped by installed composer packages (see below).
- Bundled — the rules that ship with phunkiec, in its own
macros/.
So a package's rule overrides a bundled one for the same surface syntax, and an explicitly supplied macro overrides everything.
Shipping macros from a package
A library can ship .syn macros for its own types and have phunkiec discover
them automatically. Declare a macros directory in the package's composer.json:
{
"extra": {
"phunkiec": {
"macros": "macros/"
}
}
}
Every .syn file in that directory is loaded whenever phunkiec compiles a project
that has the package installed. This is how phunkie/effect ships the pattern for
its own IO — matching an effect IO needs a rule pointing at effect's
Referenced\IO, which phunkiec itself does not know about.
Discovery uses composer's runtime metadata (Composer\InstalledVersions), so it
sees exactly the packages installed alongside the project being compiled.