Download the PHP package lunarstorm/laravel-ddd without Composer

On this page you can find all versions of the php package lunarstorm/laravel-ddd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ddd

Domain Driven Design Toolkit for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel-DDD is a toolkit to support domain driven design (DDD) in Laravel applications. One of the pain points when adopting DDD is the inability to use Laravel's native make commands to generate objects outside the App\* namespace. This package aims to fill the gaps by providing equivalent commands such as ddd:model, ddd:dto, ddd:view-model and many more.

Installation

You can install the package via composer:

You may initialize the package using the ddd:install artisan command. This will publish the config file, register the domain path in your project's composer.json psr-4 autoload configuration on your behalf, and allow you to publish generator stubs for customization if needed.

Configuration

For first-time installations, a config wizard is available to populate the ddd.php config file interactively:

For existing installations with a config file published from a previous version, you may use the ddd:config update command to rebuild and merge it with the latest package copy:

See Configuration Utility for details about other available options.

Peer Dependencies

The following additional packages are suggested (but not required) while working with this package.

The default DTO and Action stubs of this package reference classes from these packages. If this doesn't apply to your application, you may publish and customize the stubs accordingly.

Deployment

In production, ensure you run php artisan ddd:optimize during the deployment process to optimize autoloading. If you already run php artisan optimize in production, this will be handled automatically.

Version Compatibility

Laravel LaravelDDD
9.x - 10.24.x 0.x 0.x README
10.25.x 1.x
11.x 1.x
11.44.x 2.x
12.x 2.x

See UPGRADING for more details about upgrading across different versions.

Usage

Syntax

All domain generator commands use the following syntax:

Available Commands

Generators

The following generators are currently available: Command Description Usage
ddd:model Generate a domain model php artisan ddd:model Invoicing:Invoice

Options:
--migration\|-m
--factory\|-f
--seed\|-s
--controller --resource --requests\|-crR
--policy
-mfsc
--all\|-a
--pivot\|-p
ddd:factory Generate a domain factory php artisan ddd:factory Invoicing:InvoiceFactory
ddd:dto Generate a data transfer object php artisan ddd:dto Invoicing:LineItemPayload
ddd:value Generate a value object php artisan ddd:value Shared:DollarAmount
ddd:view-model Generate a view model php artisan ddd:view-model Invoicing:ShowInvoiceViewModel
ddd:action Generate an action php artisan ddd:action Invoicing:SendInvoiceToCustomer
ddd:cast Generate a cast php artisan ddd:cast Invoicing:MoneyCast
ddd:channel Generate a channel php artisan ddd:channel Invoicing:InvoiceChannel
ddd:command Generate a command php artisan ddd:command Invoicing:InvoiceDeliver
ddd:controller Generate a controller php artisan ddd:controller Invoicing:InvoiceController

Options: inherits options from make:controller
ddd:event Generate an event php artisan ddd:event Invoicing:PaymentWasReceived
ddd:exception Generate an exception php artisan ddd:exception Invoicing:InvoiceNotFoundException
ddd:job Generate a job php artisan ddd:job Invoicing:GenerateInvoicePdf
ddd:listener Generate a listener php artisan ddd:listener Invoicing:HandlePaymentReceived
ddd:mail Generate a mail php artisan ddd:mail Invoicing:OverduePaymentReminderEmail
ddd:middleware Generate a middleware php artisan ddd:middleware Invoicing:VerifiedCustomerMiddleware
ddd:migration Generate a migration php artisan ddd:migration Invoicing:CreateInvoicesTable
ddd:notification Generate a notification php artisan ddd:notification Invoicing:YourPaymentWasReceived
ddd:observer Generate an observer php artisan ddd:observer Invoicing:InvoiceObserver
ddd:policy Generate a policy php artisan ddd:policy Invoicing:InvoicePolicy
ddd:provider Generate a provider php artisan ddd:provider Invoicing:InvoiceServiceProvider
ddd:resource Generate a resource php artisan ddd:resource Invoicing:InvoiceResource
ddd:rule Generate a rule php artisan ddd:rule Invoicing:ValidPaymentMethod
ddd:request Generate a form request php artisan ddd:request Invoicing:StoreInvoiceRequest
ddd:scope Generate a scope php artisan ddd:scope Invoicing:ArchivedInvoicesScope
ddd:seeder Generate a seeder php artisan ddd:seeder Invoicing:InvoiceSeeder
ddd:class Generate a class php artisan ddd:class Invoicing:Support/InvoiceBuilder
ddd:enum Generate an enum php artisan ddd:enum Customer:CustomerType
ddd:interface Generate an interface php artisan ddd:interface Customer:Contracts/Invoiceable
ddd:trait Generate a trait php artisan ddd:trait Customer:Concerns/HasInvoices

Generated objects will be placed in the appropriate domain namespace as specified by ddd.namespaces.* in the config file.

Config Utility (Since 1.2)

A configuration utility was introduced in 1.2 to help manage the package's configuration over time.

Output:

These config tasks are also invokeable directly using arguments:

Other Commands

Advanced Usage

Application Layer (since 1.2)

Some objects interact with the domain layer, but are not part of the domain layer themselves. By default, these include: controller, request, middleware. You may customize the path, namespace, and which ddd:* objects belong in the application layer.

The configuration above will result in the following:

Output:

Custom Layers (since 1.2)

Often times, additional top-level namespaces are needed to hold shared components, helpers, and things that are not domain-specific. A common example is the Infrastructure layer. You may configure these additional layers in the ddd.layers array.

The configuration above will result in the following:

Output:

After defining new layers in ddd.php, make sure the corresponding namespaces are also registered in your composer.json file. You may use the ddd:config helper command to handle this for you.

Nested Objects

For any ddd:* generator command, nested objects can be specified with forward slashes.

This is essential for objects without a fixed namespace such as class, interface, trait, each of which have a blank namespace by default. In other words, these objects originate from the root of the domain.

Subdomains (nested domains)

Subdomains can be specified with dot notation wherever a domain option is accepted.

Overriding Configured Namespaces at Runtime

If for some reason you need to generate a domain object under a namespace different to what is configured in ddd.namespaces.*, you may do so using an absolute name starting with /. This will generate the object from the root of the domain.

Custom Object Resolution

If you require advanced customization of generated object naming conventions, you may register a custom resolver using DDD::resolveObjectSchemaUsing() in your AppServiceProvider's boot method:

The example above will result in the following:

Customizing Stubs

This package ships with a few ddd-specific stubs, while the rest are pulled from the framework. For a quick reference of available stubs and their source, you may use the ddd:stub --list command:

Stub Priority

When generating objects using ddd:*, stubs are prioritized as follows:

Publishing Stubs

To publish stubs interactively, you may use the ddd:stub command:

You may also use shortcuts to skip the interactive steps:

To publish multiple stubs with common prefixes at once, use * or . as a wildcard ending to indicate "stubs that starts with":

Output:

Domain Autoloading and Discovery

Autoloading behaviour can be configured with the ddd.autoload configuration option. By default, domain providers, commands, policies, and factories are auto-discovered and registered.

Service Providers

When ddd.autoload.providers is enabled, any class within the domain layer extending Illuminate\Support\ServiceProvider will be auto-registered as a service provider.

Console Commands

When ddd.autoload.commands is enabled, any class within the domain layer extending Illuminate\Console\Command will be auto-registered as a command when running in console.

Policies

When ddd.autoload.policies is enabled, the package will register a custom policy discovery callback to resolve policy names for domain models, and fallback to Laravel's default for all other cases. If your application implements its own policy discovery using Gate::guessPolicyNamesUsing(), you should set ddd.autoload.policies to false to ensure it is not overridden.

Factories

When ddd.autoload.factories is enabled, the package will register a custom factory discovery callback to resolve factory names for domain models, and fallback to Laravel's default for all other cases. Note that this does not affect domain models using the Lunarstorm\LaravelDDD\Factories\HasDomainFactory trait. Where this is useful is with regular models in the domain layer that use the standard Illuminate\Database\Eloquent\Factories\HasFactory trait.

If your application implements its own factory discovery using Factory::guessFactoryNamesUsing(), you should set ddd.autoload.factories to false to ensure it is not overridden.

Migrations

When ddd.autoload.migrations is enabled, paths within the domain layer matching the configured ddd.namespaces.migration namespace will be auto-registered as a database migration path and recognized by php artisan migrate.

Ignoring Paths During Autoloading

To specify folders or paths that should be skipped during autoloading class discovery, add them to the ddd.autoload_ignore configuration option. By default, the Tests and Migrations folders are ignored.

Note that ignoring folders only applies to class-based autoloading: Service Providers, Console Commands, Policies, and Factories.

Paths specified here are relative to the root of each domain. e.g., src/Domain/Invoicing/{path-to-ignore}. If more advanced filtering is needed, a callback can be registered using DDD::filterAutoloadPathsUsing(callback $filter) in your AppServiceProvider's boot method:

The filter callback is based on Symfony's Finder Component.

Disabling Autoloading

You may disable autoloading by setting the respective autoload options to false in the configuration file as needed, or by commenting out the autoload configuration entirely.

Autoloading in Production

In production, you should cache the autoload manifests using the ddd:optimize command as part of your application's deployment process. This will speed up the auto-discovery and registration of domain providers and commands. The ddd:clear command may be used to clear the cache if needed. If you are already running php artisan optimize, ddd:optimize will be included within that pipeline. The framework's optimize and optimize:clear commands will automatically invoke ddd:optimize and ddd:clear respectively.

Configuration File

This is the content of the published config file (ddd.php):

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-ddd with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
illuminate/contracts Version ^11.44|^12.0
laravel/pint Version ^1.21
laravel/prompts Version ^0.3.1
lorisleiva/lody Version ^0.6
spatie/laravel-package-tools Version ^1.19.0
symfony/var-exporter Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lunarstorm/laravel-ddd contains the following files

Loading the files please wait ....