v0.1.0
Initial release. Scaffolding and validation helpers for Laravel Value Objects.
Scaffolder
php artisan make:value-object Email --rule=email --normalize=lower --cast=Order.email generates:
- A Value Object class:
final readonly, validated, normalized, withCastable,Stringable, andJsonSerializablewired up.ComparesCastableAttributes::compare()is added when--normalizeis set, so Eloquent dirty-checking treats casing-equivalent values as equal. - A Pest test stub.
- A patched target model: the cast line gets inserted into the model's
casts()method, indented to match the existing entries.
Curated --rule values: email, url, ip, uuid, alpha_num, alpha, numeric, regex:PATTERN.
Composable normalizers: lower, upper, trim. Combine with commas (--normalize=trim,lower).
--method=name:returnType (repeatable) drops an empty method stub for your domain logic.
--type validates against PHP primitives plus any existing class.
--cast=Billing/Invoice.email resolves to nested model paths.
--dry-run, --force, --no-test, --namespace=NS round out the flag surface.
When the target model uses a shape we can't safely modify (parent::casts() merges, no casts() method), Aegis falls back to printing the snippet for you to paste manually. The VO and test files still get written.
FormRequest bridge
use Illuminate\Validation\Rule;
use HarrisRafto\Aegis\Concerns\ResolvesValueObjects;
class StoreUserRequest extends FormRequest
{
use ResolvesValueObjects;
public function rules(): array
{
return [
'email' => ['required', Rule::valueObject(Email::class)],
];
}
}
// In your controller:
$email = $request->valueObject('email'); // Email instance, already validatedRule::valueObject(...) uses any Value Object class as a Laravel validation rule by running its constructor. ResolvesValueObjects gives the FormRequest a valueObject($key) accessor that returns the already-validated instance — no second construction.
Codebase auditor
php artisan vo:scan walks your Eloquent models and migrations, flags column names matching common patterns (email, url, uuid, ip, slug, country_code, currency_code, status, money), and prints the make:value-object invocation for each candidate. A coverage statistic at the end tells you how much of your codebase is already wrapped.
--path, --migrations-path, --no-cast, --json configure the walk and the output.
Customisation
php artisan vendor:publish --tag=aegis-stubsCopies value-object.stub and value-object-test.stub into stubs/aegis.*.stub, where the generators look first before falling back to the package's bundled copies. Edit them to match your project's house style.
--tag=aegis-config publishes the config file. --tag=aegis publishes both.
Requirements
- PHP 8.3+
- Laravel 13
Built by @harrisrafto for Laravel Live Japan 2026.