nunomaduro/yorn
Yorn is a small, focused Laravel package from Nuno Maduro (Pest, Larastan). Install it with Composer and it slots neatly into an existing app, with a clean API, no heavy configuration, and the framework-native feel his packages are known for.
First, correct your mental model: despite the package description mentioning Symfony Console, nunomaduro/yorn is an experimental PHP extension/loader that adds JavaScript-style import/export syntax to PHP. You are not installing a Composer library you can use — you are adding a nonstandard language surface that must be compiled and enabled in the runtime before any file containing import/export will parse.
Minimal path:
git clone https://github.com/nunomaduro/yorn.git
cd yorn
phpize && ./configure && make && sudo make install
# then in php.ini (or a -d flag / Dockerfile layer):
# extension=yorn.so
php -m | grep -i yorn # verify it loaded
Then confirm the syntax works at all before writing anything real:
// math.php
export function add(int $a, int $b): int {
return $a + $b;
}
// index.php
import { add } from './math.php';
echo add(2, 3);
Where to look first: the tests/ directory and the extension source. With ~144 stars and zero dependents, the tests are the only reliable specification of what syntax is actually supported — the README is aspirational, the tests are behaviour. Read them before designing anything.
First use case: a throwaway spike or a self-contained CLI script in a sandboxed container. Not an existing Laravel app, not a package you intend to publish. The deliverable of your first session is a written answer to "does this parse, run, and cache predictably in our image?" — not working code.
export function / export const, never default exports. Named exports keep the dependency graph greppable and make the eventual migration to static methods mechanical.make install. A PHP minor upgrade silently invalidates the .so.use statements for vendor packages and let Composer's autoloader handle them. The boundary is: Yorn-parsed files declare no namespace; everything else is untouched Laravel/Composer.spikes/modules/) that is excluded from Pint, PHPStan, Psalm, and the Composer autoload map. If it isn't in autoload, composer dump-autoload and artisan will never trip over it.export function add() into final class Math { public static function add() } should be a fifteen-minute change.import/export. Expect red squiggles and zero autocompletion. Use per-directory exclusions/baselines rather than disabling analysis globally — degrading your whole codebase to accommodate an experiment is the wrong trade.__FILE__/__DIR__ may point at generated or cached files rather than your originals. var_dump inside the module and compare against the transformed output — that comparison will explain most "impossible" bugs../math.php resolves relative to the importing file, not the CWD. Mixing relative and absolute paths produces the least helpful error messages in the toolchain.namespace declaration and import/export will break. Hard rule: Yorn files are namespace-free.app/ and out of every autoloaded path so a colleague can composer install && artisan serve without building an extension.How can I help you explore Laravel packages today?