Laravel | address-domains |
---|---|
9.0 | ^1.0 |
salah3id/address-domains
is a Laravel package which created to manage your large Laravel app using domains with repository design pattern to abstract the data layer, making our application more flexible to maintain. Domain is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 9.
This package is a re-published, re-organised of nWidart/laravel-modules, which isn't support repository design pattern.
To install through Composer, by run the following command:
composer require salah3id/address-domains
The package will automatically register a service provider and alias.
Optionally, publish the package's configuration file by running:
php artisan vendor:publish --provider="Salah3id\Domains\LaravelDomainsServiceProvider"
By default, the domain classes are not loaded automatically. You can autoload your domains using psr-4
. For example:
{
"autoload": {
"psr-4": {
"App\\": "app/",
"Domains\\": "Domains/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
}
Tip: don't forget to run composer dump-autoload
afterwards.
Generate your first domain using :
php artisan domain:make Address
The following structure will be generated.
app/
bootstrap/
vendor/
Domains/
│ ├── Address/
│ │ ├── Assets/
│ │ ├── Config/
│ │ ├── Console/
│ │ ├── Database/
│ │ │ ├── Migrations/
│ │ │ ├── Seeders/
│ │ ├── Entities/
│ │ ├── Http/
│ │ │ ├── Controllers/
│ │ │ ├── Middleware/
│ │ │ ├── Requests/
│ │ ├── Providers/
│ │ │ ├── AddressServiceProvider.php
│ │ │ ├── RepositoryServiceProvider.php
│ │ │ ├── RouteServiceProvider.php
│ │ ├── Resources/
│ │ │ │ ├── assets/
│ │ │ │ │ ├── js/
│ │ │ │ │ │ ├── app.js
│ │ │ │ │ ├── sass/
│ │ │ │ │ │ ├── app.scss
│ │ │ │ ├── lang/
│ │ │ │ ├── views/
│ │ ├── Routes/
│ │ │ ├── api.php
│ │ │ ├── web.php
│ │ ├── Repositories/
│ │ ├── Tests/
│ │ ├── composer.json
│ │ ├── module.json
│ │ ├── package.json
│ │ ├── webpack.mix.js
│ │ └──
│ └── Other Domains ...
└── ... etc
Generate multiple domains using :
php artisan domain:make Address User Admin Blog
Parameter | Description |
---|---|
--plain , -p |
By default when you create a new domain, the command will add some resources like a controller, seed class, service provider, etc. automatically. If you don't want these, you can add --plain flag, to generate a plain domain. |
Because we are autoloading the modules using psr-4, we strongly recommend using StudlyCase convention.
Generate a new domain
php artisan domain:make Address
Generate multiple domains at once.
php artisan domain:make Address User Admin
This allows you to not specify the doamin name on other commands requiring the module name as an argument.
php artisan domain:use Address
This unsets the specified domain that was set with the domain:use
command.
php artisan domain:unuse Address
List all available domains.
php artisan domain:list
Migrate the given domain, or without a domain an argument, migrate all domains.
php artisan domain:migrate Address
Rollback the given domain, or without an argument, rollback all domains.
php artisan domain:migrate-rollback Address
Refresh the migration for the given module, or without a specified module refresh all modules migrations.
php artisan domain:migrate-refresh Address
Reset the migration for the given domain, or without a specified domain reset all domains migrations.
php artisan domain:migrate-reset Address
Seed the given domain, or without an argument, seed all domains
php artisan domain:seed Address
Publish the migration files for the given domain, or without an argument publish all domains migrations.
php artisan domain:publish-migration Address
Publish the given domain configuration files, or without an argument publish all domains configuration files.
php artisan domain:publish-config Address
Publish the translation files for the given domain, or without a specified domain publish all domains migrations.
php artisan domain:publish-translation Address
Enable the given domain.
php artisan domain:enable Address
Disable the given domain.
php artisan domain:disable Address
Update the given domain.
php artisan module:update Blog
The MIT License (MIT). Please see License File for more information.