Download the PHP package deyan-ardi/laravel-layerize without Composer
On this page you can find all versions of the php package deyan-ardi/laravel-layerize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deyan-ardi/laravel-layerize
More information about deyan-ardi/laravel-layerize
Files in deyan-ardi/laravel-layerize
Package laravel-layerize
Short Description Package to implement Layerize Architecture in Laravel
License MIT
Informations about the package laravel-layerize
Laravel Layerize - Develop Laravel App With Layer Architecture
What Is Layer Architecture
In the Laravel Framework, the standard uses an architecture, namely MVC (Model - View - Controller). This architecture is also included in the example of implementing the Layer Architecture, but there are obstacles that are encountered when we only implement MVC.
This problem is mainly encountered when we start developing a complex and continuous Laravel-based application, the MVC Architecture cannot handle it as a whole because all business logic is located only in the Controller. So if there is a change in the development team, the newly joined team will spend a lot of time studying the previous code.
One of the things that can be done to overcome is to develop from the standard Laravel Framework architecture to a more Clean Code architecture, but the problem is that there is no official standard for this and many novice programmers find it difficult to learn it.
With Laravel Layerize, you can separate the business logic from the Controller and organize your code into clear, separate layers. This package provides a ready-to-use directory structure and best practice approach to organize code according to their respective functions
The Laravel Layerize package has several layers namely:
- Presentation Layer: The layer closest to the user or the "presentation" of the application. Its main tasks include handling user interaction, such as receiving user input, displaying views, and sending responses to the user. Components in this layer include route, controllers, dto or form validation
- Business Layer: The layer that contains the business logic or business rules of the application. Its main tasks include orchestrating business processes, performing validation, making decisions, and processing data. This layer is technology-agnostic and responsible for keeping the business logic isolated from other implementation details. Components in this layer include use cases.
- Persistence Layer: The layer responsible for storing and retrieving data from persistent resources, such as databases or file storage. Its main tasks include performing CRUD (Create, Read, Update, Delete) operations on data. This layer provides an interface to access persistent resources and enables the application to store and retrieve data. Components in this layer include Command Service, Query Service, Datatable Service, and Other Service depend on requirements
- Database Layer: The layer that directly refers to the database system used by the application. It involves components such as the database server, database schema, tables, and queries. This layer serves as the infrastructure that supports the persistence layer in storing and retrieving data from the database.
By adopting a Laravel Layerize, applications can be well organized, have a clear structure, and separate responsibilities between each layer. This allows for easier maintenance, more structured development, and increases the scalability and flexibility of your application.
Laravel Support Version
Laravel Version | Support |
---|---|
4.2.x | No |
5.x.x | No |
6.x.x | No |
7.x.x | Yes |
8.x.x | Yes |
9.x.x | Yes |
10.x.x | Yes |
System Requerements
- PHP Version "^7.3|7.4|^8.0|^8.1|^8.2"
- File (Default By Laravel Illuminate)
How To Install
-
Open terminal, run this command
- After finish install, you can start use this package by run the command
How To Update
- Open terminal, run this command
How To Use (Documentation By Layer)
Information
This package support folder generate, you can use "/" for create file in the folder (Ex: Admin/KonfigurasiController => to create class KonfigurasiController in Admin folder)
Presentation Layer
Route
There are no changes to the route, you can implement the route according to the Laravel framework standards
DTO/Validation
DTO/Validation in Laravel Framework is handled by FormRequest. This package helps you create a FormRequest framework for you to validate on the user request side before going to the Controller. To create a FormRequest with Layerize, use the following command
The result of the above command will give a class named StoreUserRequest
which will be added to the App/Http/Requests/User
folder
Controller
This package helps you create a Controller framework for you to send requests to the next layer. To create a Controller with Layerize, use the following command
The result of the above command will give a class named UserController
which will be added to the App/Http/Controllers
folder
Business Layer
Use Case
This package helps you create a UseCase framework for you to perform business logic on your application. To create a UseCase with Layerize, use the following command
The result of the above command will give a class named UserUseCase
which will be added to the App/Http/UseCase
folder
Persistance Layer
Generate All Service Default (QueryService, DatatableService, CommandService)
This package helps you framework all the default services for you to interact with the database layer. To make all services default with Layerize, use the following command
The result of the above command will give three class named UserQuery
,UserCommand
,UserDatatable
which will be added to the App/Services/UserPage/User
folder
-
UserQuery.php
-
UserCommand.php
UserDatatable.php
Generate Single Service
This package helps you framework a services for you to interact with the database layer. To make a services default with Layerize, use the following command
The result of the above command will give a class named ApiProvider
which will be added to the App/Services/UserPage
folder
Database Layer
Model
There are no changes to the model, you can implement the model according to the Laravel framework standards
General Query Service Function
By configuring the Query Service, we provide some simple custom functions that can be used in Use Case to speed up the process of querying the database
Configuration
- Create Query Service
-
Add Model name in __construction Query Service Class
-
Call Query Service in Use Case
- One Query Service only can integrate with One Model, you can make many Query Service instances of Service
FirstOrFail
-
Default parameters
firstOrFail($where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
First
-
Default parameters
first($where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
Get
-
Default parameters
get($where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
GetCount
-
Default parameters
getCount($where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
Paginate
-
Default parameters
paginate($perPage = 10, $where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
Pluck
-
Default parameters
pluck($column, $where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
Chunk
-
Default parameters
chunk($size, $callback, $where = [], $with = [], $orderBy = null, $orderDirection = 'asc')
- Example usage
First Or New
-
Default parameters
firstOrNew($where = [], $attributes = [])
- Example usage
Contributing
- GanaDev Com
- Open Source, to contribution please read CONTRIBUTING.md
Version
- v2.0.0
License
The Laravel Layerize is open-sourced software licensed under the MIT license.