Download the PHP package aesircloud/laravel-domains without Composer
On this page you can find all versions of the php package aesircloud/laravel-domains. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aesircloud/laravel-domains
More information about aesircloud/laravel-domains
Files in aesircloud/laravel-domains
Package laravel-domains
Short Description A Laravel package for rapid domain driven development.
License MIT
Homepage https://github.com/AesirCloud/laravel-domains
Informations about the package laravel-domains
aesircloud/laravel-domains
A Laravel package to scaffold Domain-Driven Design (DDD) structures in your Laravel projects. This package creates a complete suite of files—domain entities, value objects, repositories, domain services, models (with optional soft deletes), factories, observers, policies, and even migrations—so you can quickly get started with a DDD approach.
FEATURES
-
Domain Scaffolding Automatically creates directories and stub files for a new domain.
-
Model Generation Generates a domain model extending your BaseModel with optional soft delete support.
-
Factory, Observer, & Policy Generates a factory, observer, and policy for your domain.
-
Optional Migrations Create migrations (with or without soft deletes) for your domain’s table.
-
Repository Binding Automatically updates your RepositoryServiceProvider with the new domain’s repository binding.
-
CRUD Actions Generates a full set of CRUD actions (Create, Update, Delete, Index, Show) using
lorisleiva/laravel-actions
. -
Optional Soft Delete Actions When the domain uses soft deletes, additional Restore and ForceDelete actions are generated.
-
Value Object Generation Use the make:value-object command to scaffold a new value object. Optionally specify a domain to place the value object within that domain’s folder.
-
Interactive Prompts If a file already exists, you'll be prompted (defaulting to replace) so you can control file overwrites.
-
--force Option Overwrite existing files without being prompted.
- Customizable Stubs Publish the package stubs for customization.
INSTALLATION
Install the package via Composer:
Laravel’s package auto-discovery will register the service provider automatically. If you need to manually register it, add the following to your config/app.php
providers array:
PUBLISHING STUBS
To customize the stub files used for scaffolding, publish the package stubs:
This will copy all stub files into stubs/laravel-domains
in your project, where you can modify them as you wish.
USAGE
To scaffold a new domain, run the following command:
HOW DOMAIN NAMING WORKS
- Class Names: DomainName is automatically converted to StudlyCase.
- Table Names: The table name is derived from your raw domain input, converted to snake_case and pluralized.
Example: php artisan make:domain user_profile
- Domain class name: UserProfile
- Table name: user_profiles
BASIC EXAMPLES
1) Basic Domain Creation
Creates domain files under app/Domains/User/
Generates a User model, factory, observer, policy, DTO, repository interface, and domain service.
2) Domain with Migration
Also creates a migration in the database/migrations
folder.
3) Domain with Soft Deletes
Model, observer, policy, repository, and actions will include soft-delete logic.
4) Domain with Migration and Soft Deletes
5) Force Overwrite of Existing Files
Automatically overwrites any existing files without prompting.
The command will:
- Create domain directories (e.g.,
app/Domains/User/Entities
,Repositories
,DomainServices
). - Generate stub files for Entity, Repository Interface, and Domain Service.
- Create a BaseModel (if not already present) and a domain-specific model in
app/Models
(using soft delete logic if selected). - Create a DTO file using spatie/laravel-data in
app/Domains/User/DataTransferObjects
. - Create a factory in
database/factories
. - Create an observer in
app/Observers
and a policy inapp/Policies
. - Optionally generate a migration file (using stubs from
stubs/model
). - Update the RepositoryServiceProvider with the binding for the new domain’s repository interface and its concrete implementation.
- Generate CRUD actions (Create, Update, Delete, Index, Show), with optional Restore and ForceDelete actions if soft deletes are enabled.
MAKING A SUBDOMAIN
To create a subdomain within an existing domain, use the make:subdomain
command:
EXAMPLES
Example: Under the 'User' domain, create a 'AuthenticationLogs' subdomain
- Also creates actions in app/Actions/{ParentDomain}/{SubdomainName}, e.g. app/Actions/User/AuthenticationLogs/DeleteAuthenticationLogAction.php.
- Binds the repository to RepositoryServiceProvider.
NOTE: The parent domain (e.g. app/Domains/User) must already exist before you can add a subdomain within it.
- You can make a folder in the
app/Domains/<domain>
directory to represent a parent domain that you do not need to scaffold. E.g.,app/Domains/HumanResources
. Then you can create subdomains within that folder. - Example:
php artisan make:subdomain HumanResources Payroll --migration --soft-deletes
MAKING A VALUE OBJECT
You can also generate a value object, optionally scoping it to a domain:
Creates a file named AddressValueObject.php in app/ValueObjects
.
Or specify a domain:
Or specify a domain and subdomain:
You can also use the --force
option to overwrite existing files:
REQUIREMENTS
- PHP: 8.3 or higher
- Laravel: 11.42 or higher
- illuminate/console: 11.42 or higher
- illuminate/support: 11.42.1 or higher
- spatie/laravel-data: 4.13 or higher
- aesircloud/sluggable: 1.1.0 or higher
- lorisleiva/laravel-actions: 2.8.6 or higher
DESIGN AND DEVELOPMENT STANDARDS
Please see the Standards & Pattern Philosophy file for the design and development standards used in this package.
Security
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
LICENSE
The MIT License (MIT). Please see License file for more information.
All versions of laravel-domains with dependencies
illuminate/console Version ^11.42|^12.0
illuminate/support Version ^11.42.1|^12.0
laravel/framework Version ^11.42|^12.0
spatie/laravel-data Version ^4.13
aesircloud/sluggable Version ^1.1
aesircloud/laravel-actions Version ^1.0