Code Monkey home page Code Monkey logo

address-domains's Introduction

Laravel-Domains

Latest Version on Packagist Software License Scrutinizer Coverage Quality Score Total Downloads

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.

Install

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"

Autoloading

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.

Creating a Domain

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

domain:make command options

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.

Naming convention

Because we are autoloading the modules using psr-4, we strongly recommend using StudlyCase convention.

Utility commands

domain:make

Generate a new domain

  php artisan domain:make Address

domain:make

Generate multiple domains at once.

  php artisan domain:make Address User Admin 

domain:use

This allows you to not specify the doamin name on other commands requiring the module name as an argument.

  php artisan domain:use Address 

domain:unuse

This unsets the specified domain that was set with the domain:use command.

  php artisan domain:unuse Address 

domain:list

List all available domains.

  php artisan domain:list 

domain:migrate

Migrate the given domain, or without a domain an argument, migrate all domains.

  php artisan domain:migrate Address

domain:migrate-rollback

Rollback the given domain, or without an argument, rollback all domains.

  php artisan domain:migrate-rollback Address

domain:migrate-refresh

Refresh the migration for the given module, or without a specified module refresh all modules migrations.

  php artisan domain:migrate-refresh Address

domain:migrate-reset

Reset the migration for the given domain, or without a specified domain reset all domains migrations.

php artisan domain:migrate-reset Address

domain:seed

Seed the given domain, or without an argument, seed all domains

php artisan domain:seed Address

domain:publish-migration

Publish the migration files for the given domain, or without an argument publish all domains migrations.

php artisan domain:publish-migration Address

domain:publish-config

Publish the given domain configuration files, or without an argument publish all domains configuration files.

php artisan domain:publish-config Address

domain:publish-translation

Publish the translation files for the given domain, or without a specified domain publish all domains migrations.

php artisan domain:publish-translation Address

domain:enable

Enable the given domain.

php artisan domain:enable Address

domain:disable

Disable the given domain.

php artisan domain:disable Address

domain:update

Update the given domain.

php artisan module:update Blog

Credits

License

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

address-domains's People

Contributors

salah3id avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.