PHPackages                             deyan-ardi/laravel-layerize - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. deyan-ardi/laravel-layerize

ActiveLibrary[Framework](/categories/framework)

deyan-ardi/laravel-layerize
===========================

Package to implement Layerize Architecture in Laravel

v2.0.0(2y ago)2109MITPHPPHP ^7.3|7.4|^8.0|^8.1|^8.2

Since May 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/deyan-ardi/laravel-layerize)[ Packagist](https://packagist.org/packages/deyan-ardi/laravel-layerize)[ RSS](/packages/deyan-ardi-laravel-layerize/feed)WikiDiscussions v2.x.x Synced 1mo ago

READMEChangelog (2)DependenciesVersions (10)Used By (0)

Laravel Layerize - Develop Laravel App With Layer Architecture
==============================================================

[](#laravel-layerize---develop-laravel-app-with-layer-architecture)

[![Laravel](https://camo.githubusercontent.com/3f85d3450d8cca297d3e2f21341cf46297ec738734e4135ecc1f6132e63c4f48/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d253545372e302d7265642e737667)](https://laravel.com/)[![PHP](https://camo.githubusercontent.com/757ea8be6fbd04bf12d0794d9b7c3c48bff9cb5f9b0e132fadb0927d6db00a6c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545372e332d626c75652e737667)](https://www.php.net/)

What Is Layer Architecture
--------------------------

[](#what-is-layer-architecture)

 [![Gambar](https://camo.githubusercontent.com/4d754b33fa4c8b5ed4b9488dfbfb599d05316edc762767371b8c4786ae7db3b0/68747470733a2f2f7376312e7374617469632e67616e616465762e636f6d2f646579616e2f6c617965722d6172636869746563747572652e706e67)](https://camo.githubusercontent.com/4d754b33fa4c8b5ed4b9488dfbfb599d05316edc762767371b8c4786ae7db3b0/68747470733a2f2f7376312e7374617469632e67616e616465762e636f6d2f646579616e2f6c617965722d6172636869746563747572652e706e67)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-support-version)

Laravel VersionSupport4.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
-------------------

[](#system-requerements)

- PHP Version "^7.3|7.4|^8.0|^8.1|^8.2"
- File (Default By Laravel Illuminate)

How To Install
--------------

[](#how-to-install)

- Open terminal, run this command

    ```
    composer require deyan-ardi/laravel-layerize --dev
    ```
- After finish install, you can start use this package by run the command

How To Update
-------------

[](#how-to-update)

- Open terminal, run this command

    ```
    composer update deyan-ardi/laravel-layerize
    ```

How To Use (Documentation By Layer)
-----------------------------------

[](#how-to-use-documentation-by-layer)

### Information

[](#information)

This package support folder generate, you can use "/" for create file in the folder (Ex: Admin/KonfigurasiController =&gt; to create class KonfigurasiController in Admin folder)

### Presentation Layer

[](#presentation-layer)

#### Route

[](#route)

There are no changes to the route, you can implement the route according to the Laravel framework standards

#### DTO/Validation

[](#dtovalidation)

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

```
php artisan layerize:dto User/StoreUserRequest
```

The result of the above command will give a class named `StoreUserRequest` which will be added to the `App/Http/Requests/User` folder

```
