m-tech-stack / base-package
This Project Base For Using Modules
Requires
- nwidart/laravel-modules: 9.0.2
- tucker-eric/eloquentfilter: ^3.4
This package is auto-updated.
Last update: 2025-04-23 16:10:20 UTC
README
Composer Require
composer require m-tech-stack/base-package
Run Vendor
php artisan vendor:publish --tag="base-package" --force
How To Use
Create New Module
php artisan module:make ModuleName
Create New Module inside Folder
- Main Module ( Ex. Payment )
- Sub Module ( Urway )
php artisan module:make ModuleName MainModule
Create Migration inside module assuming Module is User
php artisan module:make-migration create_users_table User
You can follow this structure for any other supported artisan commands
php artisan module:make-{artisan-action} ModuleName
Similar to
php artisan make:{artisan-action}
Structure
All application files will be under app folder we have the following
-
Console
- Contains Custom Commands to be called like php artisan ScrapeHotelsCommand
- Contains Kernel that where we can configure schedules and import the commands
-
Data - it contains Data Classes
- Data classes are used to return well-structured data for a payload.
- Data classes are very useful to transfer data between the system components in a maintainable way
-
DTOs
- DTO (Data Transfer Object) is a simple utility and a small component that can be used to transfer data between the outside world to the inside world of either the Domain or the Module.
-
Exception - Here where we create our custom exceptions
-
Handlers - Used to make an action without need any feedback delete action for example or run a statement
-
Http
- Controllers ( Contains the controllers that use to handle outside requests and the presentation of data and communicating with routes,services to make the request )
- Middleware ( Convenient mechanism for inspecting and filtering HTTP requests entering the application like how we use it at Auth )
- Requests ( Where we create the expected requests and define their rules )
- Kernel ( The place where we define the middlewares )
-
Jobs - Here we create the jobs needed to be dispatched in the Queues.
-
Models - Contains all of your Eloquent model classes
-
Presenters
- Instead of outputting all the model fields and their loaded relationship,
- We can basically format that to an agreed structure that will output only the needed data and also rename fields
- To be more convenient than the original names in models or datasets
- We use AbstractPresenter to make Presenter support both Collection or single item
-
Providers - Service providers are the central place to configure the application
-
Repositories - provides an abstraction layer between the application logic and the data persistence layer
- We can say this is a middle man the handle the communication between Services and the Models
-
Services - Services are the basic classes to run logic.
-
Database
- Migration - Migrations are like version control for your database, allowing your team to modify and share the application's database schema
- Factories - define database records in a predictable and easily replicable way
- Seeders - the ability to seed your database with data using seed classes
-
Routes - The route is a way of creating a request URL for your application