sabbir-rupom / laravel-domain-oa-boilerplate

Laravel application boilerplate based on Domain Oriented Architecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Version PHP Badge License

Laravel Domain Oriented Architecture Boilerplate

Laravel boilerplate for building Domain Oriented Architecture based web application.

Installation

  • Clone the git repository git clone https://github.com/sabbir-rupom/laravel-domain-oa-boilerplate.git
  • Install & Update libraries with composer update
  • Rename and set your Server Configuration in .env.
  • Excecute following commands:
    • php artisan key:generate
    • php artisan clear:all # combination of cache:clear & optimize
    • php artisan migrate:fresh --seed # Optional

NOTE: .../project-root/app/Core/* holds the Domain Mechanism of this project.

Create New Domain

  • Enter command to create new Domain space: php artisan domain:new DomainName
    • For REST-API, you can hit command like: php artisan domain:new YourDomain --api

On successful command run, a new domain[YourDomain] will be created under project-root/app/Domains.

Initial Folder Structure of a Domain

Development Guide

  • Create new controller: php artisan domain:new:controller DomainName ControllerName

  • Create new request: php artisan domain:new:request DomainName RequestName

  • Create new middleware: php artisan domain:new:middleware DomainName MiddlewareName

  • Create new model: php artisan domain:new:model DomainName ModelName

    • If you wish to create a create-table-migration file as well: php artisan domain:new:model DomainName ModelName --m
  • Create new migration: php artisan domain:new:migration DomainName name_table_migration

    • You can use the options like --create , --table , --path command options like the existing make:migration command structure
  • Create new seeder: php artisan domain:new:seeder DomainName SeederName

Domain core service will automatically detect all the domain changes and will initialize each domain routes, migrations, seeders etc. during application run.

NOTE: Do not forget to clear cache and optimize routes if any new major changes occured inside Domains.

Domain Configuration

Configuration parameter of each Domain should be defined in app\Domains\DomainName\config\domain.php You can retrieve enabled domain information through \Illuminate\Support\Facades\Cache::get('app_domains')

CSS / JS compile with Laravel mix

CSS and Javascript files under resources folder in Domains will be compiled automatically with laravel-mix webpack command

NOTE: Do not change the webpack.mix.js file arbitrarily, the default mix configuration may hamper the auto domain-resource compilation process.

Example

  • Check the branch Example - 1 for study. ( with old laravel 8 )

If you liked this project, don't forget to give a star rating to this project repository. 😄

License

This project is licensed under the MIT License.

About

Laravel application boilerplate based on Domain Oriented Architecture

License:MIT License


Languages

Language:PHP 90.3%Language:Blade 4.3%Language:JavaScript 4.0%Language:Shell 0.9%Language:SCSS 0.4%Language:CSS 0.1%Language:HTML 0.0%