spiral/reactor
Spiral Reactor is a small PHP package for building and running reactive pipelines in Spiral apps. It helps compose transformations and event-driven flows with a simple API, aimed at lightweight orchestration and experimentation in Spiral-based projects.
Start by installing the package via Composer (composer require spiral/reactor) and examining the spiral/reactor namespace in the original spiral/framework repo (this is a read-only subtree split). Key entry points are the Spiral\Reactor classes like ClassDecorator, MethodDecorator, and PropertyDecorator, which let you programmatically generate or modify PHP classes using an object-oriented, declarative API. The most basic use case is scaffolding new classes or modifying existing ones (e.g., adding traits, methods, or attributes) at build time—commonly used in command-line tools or framework bootstrappers.
Spiral\Reactor\ClassDecorator to define class templates with methods, properties, and attributes in PHP, then call generate() to produce raw PHP source code.ClassDecorator::fromClassReflection() to load an existing class, apply decorators (e.g., addMethod(), addTrait()), and output the updated source—useful for code transformations in CLI tools.php app make:api-resource).ApiResourceDecorator that sets up @resource attributes, toArray(), and validation rules) and extend them for domain-specific scaffolding.fromClassReflection() can’t infer docblock annotations not present in compiled reflection—custom decorators may require duplicating annotation parsing logic.php-cs-fixer or phpfmt to ensure PSR compliance.spiral/framework for updates and patch manually if needed.generate() output with PHPUnit::assertStringContainsString() or snapshot testing.How can I help you explore Laravel packages today?