mykiwi / castor-extended
Makefile logic for Castor
Requires
- php: >=8.4
- symfony/finder: ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- jolicode/castor: ^1.7
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.0
- symfony/filesystem: ^7.0 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
⚠️ Pet project (for now) made with LLMs 🦾
Reusable helpers for Castor tasks, not (yet) part of Castor core.
Usage
#[Target]/#[Requires]
Makefile-style rebuild logic: turn a plain function into a rebuild recipe
with #[Target], then run it before a task's own body — but only if needed
— by referencing its name with #[Requires].
use Castor\Attribute\AsTask; use Mykiwi\CastorExtended\Attribute\{Requires, Target}; use function Castor\run; #[Target(deps: 'composer.lock', update: true)] function vendor(): void { run('composer install --no-interaction'); } #[Target(target: 'public/bundles', deps: ['vendor', 'config/bundles.php'], update: true)] #[Requires('vendor')] function assets(): void { run('bin/console assets:install public'); } #[AsTask(description: 'Start the local dev server')] #[Requires('assets')] function serve(): void { run('symfony serve'); }
Full parameter reference and failure/concurrency semantics live in the
attributes' own docblocks (linked above). Need a Finder, or a one-off
rebuild no task shares? Call make() directly — it's the
primitive #[Target] itself is built on.
Installation
As a Castor remote import (recommended for consuming projects)
castor composer init # creates castor.composer.json, once
castor composer require mykiwi/castor-extended
Commit castor.composer.json and castor.composer.lock. Then add the import
to castor.php, once:
use function Castor\import; use Mykiwi\CastorExtended\Attribute\{Requires, Target}; import('composer://mykiwi/castor-extended');
See examples for a working copy of these three files.
Contributing / local development
A devenv shell (devenv shell) provides PHP 8.5,
Composer and Castor with no manual install.
Dev tooling is a plain Makefile, not Castor — root
castor.php is the library's own import entrypoint, so it
can't also carry dev tasks:
make cs # apply php-cs-fixer make test # run phpunit make stan # run phpstan make ci # run everything above make build # build castor bundled with this library (see nix/build.nix)