The Clean Arch Maker package is a Laravel scaffolding tool designed to accelerate the implementation of Clean Architecture principles. To get started, install via Composer:
composer require effective-sloth/clean-arch-maker
Publish the configuration (if needed) and run the generator for your first use case—typically a domain entity or use case. For example, to generate a new entity with a presenter:
php artisan make:clean-arch-entity User
php artisan make:clean-arch-presenter UserPresenter --serialize # New in v1.3.0
Key files to explore:
config/clean-arch-maker.php (customize paths/namespaces)app/Domain/Entities/ (generated entities)app/Domain/Presenters/ (generated presenters)php artisan make:clean-arch-entity Post --with-migration
--serialize flag (v1.3.0) adds a serialize() method to presenters, enabling easy JSON conversion:
$presenter = new UserPresenter($user);
$data = $presenter->serialize(); // Returns array for JSON
public function show(User $user)
{
return response()->json((new UserPresenter($user))->serialize());
}
resources/stubs/ to enforce team conventions.*Presenter (e.g., UserPresenter). Override in config if your team uses a different convention.serialize() method assumes Arrayable or JsonSerializable. Ensure your presenter properties are public or use getters.migrations_path in the config.php artisan view:clear
php artisan config:clear
var_dump($presenter->serialize()) to check output structure.EntityGenerator or PresenterGenerator classes in app/Generators/ to support custom attributes.serialize() method in your presenter to include/exclude fields:
public function serialize(): array
{
return array_merge(parent::serialize(), ['custom_field' => $this->entity->customField]);
}
public function __construct(private UserPresenter $presenter) {}
How can I help you explore Laravel packages today?