Looking to hire Laravel developers? Try LaraJobs

laravel-domain-toolkit maintained by reizucodes

Description
Laravel toolkit for layered architecture with repositories, services, DTOs, and domain scaffolding.
Last update
2026/03/27 15:00 (v2.0.4)
License
Links
Downloads
5

Comments
comments powered by Disqus

Laravel Domain Toolkit

A Laravel toolkit that scaffolds a layered architecture using repositories, services, DTOs, and domain-oriented generators.
It helps enforce separation of concerns and promotes scalable, testable application design.


Requirements

  • PHP 8.1 or higher
  • Laravel 9, 10, 11, 12 and 13

Compatibility

This package supports:

  • Laravel 9.x
  • Laravel 10.x
  • Laravel 11.x
  • Laravel 12.x
  • Laravel 13.x (Experimental)

Supporting Links

Resources related to repository patterns, service layers, and domain-oriented design.

Architecture & Domain Design

Laravel Foundations


Installation

Step 1: Install via Composer

composer require reizucodes/laravel-domain-toolkit

Step 2: Register the Service Provider (If Needed)

Laravel supports package auto-discovery, so this step is usually unnecessary.

If auto-discovery is disabled, manually register the service provider:

Laravel 10 and Below

Add to config/app.php:

'providers' => [
    BlaiseBueno\LaravelDomainToolkit\DomainToolkitServiceProvider::class,
],

Laravel 11 and Above

Add to bootstrap/providers.php:

return [
    BlaiseBueno\LaravelDomainToolkit\DomainToolkitServiceProvider::class,
];

Step 3: Publish Toolkit Resources

php artisan vendor:publish --tag=laravel-domain-toolkit

This will publish:

app/Repositories/BaseRepository.php
app/Repositories/Interfaces/EloquentInterface.php
app/Providers/RepositoryServiceProvider.php

stubs/domain-toolkit/
├── repository.stub
├── repository-interface.stub
├── service.stub
└── dto.stub

Publishing installs required base classes and stub templates used by the generators.

The published stubs allow you to customize how repositories, services, and DTOs are generated.

You must publish the toolkit before using the generators.

Use --force to overwrite existing files:

php artisan vendor:publish --tag=laravel-domain-toolkit --force

Repository Bindings

Repository bindings are handled through:

app/Providers/RepositoryServiceProvider.php

Laravel 11 and Above

No manual registration is required.
Laravel automatically loads providers inside the app/Providers directory.

Laravel 10 and Below

Register the provider in config/app.php:

App\Providers\RepositoryServiceProvider::class,

Smart Class Resolution

If your application defines:

  • App\Support\ServiceReturn

The toolkit will automatically use your existing implementation.
Otherwise, it falls back to the package default.


Commands

All commands are registered automatically via the package.
No manual registration is required.


Service Return

The toolkit provides a ServiceReturn helper to standardize responses from the service layer.

It encapsulates:

  • data
  • errors
  • HTTP status codes

Example:

return ServiceReturn::success($data);

return ServiceReturn::clientError('Invalid input');

You can convert responses to JSON:

return $serviceResult->toJsonResponse();

If your application defines:

App\Support\ServiceReturn

it will be used when generating services via make:service instead of the package default.


Usage

The toolkit provides generators for common architecture components.


Generate a Repository

php artisan make:repository User

Creates:

app/Repositories/UserRepository.php
app/Repositories/Interfaces/UserInterface.php

Also registers the binding in:

app/Providers/RepositoryServiceProvider.php

Generate a Service

php artisan make:service User

Creates:

app/Services/UserService.php

Generate a DTO

php artisan make:dto CreateUserDTO

Creates:

app/DTO/CreateUserDTO.php

You may optionally specify a folder:

php artisan make:dto CreateUserDTO Auth

Creates:

app/DTO/Auth/CreateUserDTO.php

Generate a Full Domain Scaffold

php artisan make:domain User

Creates:

app/Models/User.php
app/Http/Controllers/UserController.php
app/Repositories/UserRepository.php
app/Repositories/Interfaces/UserInterface.php
app/Services/UserService.php

This command orchestrates the generators and sets up a complete domain layer.


Stub Customization

All generator templates are published to:

stubs/domain-toolkit/

You may modify these files to customize generated classes.


License

This package is open-source and available under the MIT license.