Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Clean Arch Maker Laravel Package

effectivesloth/clean-arch-maker

View on GitHub
Deep Wiki
Context7

Getting Started

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)

Implementation Patterns

Core Workflow

  1. Generate Entities: Scaffold domain models with validation rules, factories, and migrations.
    php artisan make:clean-arch-entity Post --with-migration
    
  2. Generate Presenters: Convert entities to DTOs for API responses or UI layers. The new --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
    
  3. Use Cases: Create application services to orchestrate business logic between entities and infrastructure.

Integration Tips

  • API Layer: Use presenters in controllers to transform entities:
    public function show(User $user)
    {
        return response()->json((new UserPresenter($user))->serialize());
    }
    
  • Testing: Mock presenters to isolate domain logic from HTTP layers.
  • Customization: Override generated stubs in resources/stubs/ to enforce team conventions.

Gotchas and Tips

Pitfalls

  • Presenter Naming: Default presenter names follow *Presenter (e.g., UserPresenter). Override in config if your team uses a different convention.
  • Serialization Conflicts: The new serialize() method assumes Arrayable or JsonSerializable. Ensure your presenter properties are public or use getters.
  • Migration Paths: If you move migrations post-generation, update the migrations_path in the config.

Debugging

  • Generator Issues: Clear cached views and config:
    php artisan view:clear
    php artisan config:clear
    
  • Presenter Serialization: Debug with var_dump($presenter->serialize()) to check output structure.

Extension Points

  • Add Fields Dynamically: Extend the EntityGenerator or PresenterGenerator classes in app/Generators/ to support custom attributes.
  • Custom Serialization: Override the serialize() method in your presenter to include/exclude fields:
    public function serialize(): array
    {
        return array_merge(parent::serialize(), ['custom_field' => $this->entity->customField]);
    }
    
  • Use Case Dependencies: Inject presenters into use cases for direct serialization:
    public function __construct(private UserPresenter $presenter) {}
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky