PHPackages                             si-dev/laravel-layered - 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. si-dev/laravel-layered

ActiveLibrary

si-dev/laravel-layered
======================

Package for using layered structure in Laravel.

1.0.1(6y ago)061MITPHP

Since Dec 19Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Serhii75/laravel-layered)[ Packagist](https://packagist.org/packages/si-dev/laravel-layered)[ RSS](/packages/si-dev-laravel-layered/feed)WikiDiscussions master Synced today

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

Package for using layered structure in Laravel.
===============================================

[](#package-for-using-layered-structure-in-laravel)

[![StyleCI](https://camo.githubusercontent.com/5c031d977e0921a6fa4787944b0aa25dcee5ddafd9fd2de9e1484a2e84f1d277/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3232383934343236352f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/228944265) [![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

This is an open source Laravel package which is intended primarily for those developers who uses the layered structure, like:

`model - repository - service - controller`

or

`model - service - controller`.

Actually, the package allows to create any classes, interfaces, traits that you want.

Features
--------

[](#features)

- list of new artisan make commands: class, trait, contract, repository, service, layered-bunch
- almost every command (except trait) has options
- you can inherit abstract package classes, but if that doesn't suit you, you can create your base classes and inherit them
- the same is about interfaces - you can implement or extend the provided interfaces or write your own base interfaces

Installation
------------

[](#installation)

```
composer require si-dev/laravel-layered
```

Then run command:

`php artisan vendor:publish --provider="SiDev\LaravelLayered\LayeredServiceProvider"`

> Package will use its own base repository and service classes and interfaces, but if you want to use yours, you can redefine them in config/layered.php.

Artisan commands and usage
--------------------------

[](#artisan-commands-and-usage)

### make:contract

[](#makecontract)

creates a contract (interface) with the given name. It is also possible to specify an extensible interface.

**Options**

```
-e, --extends=EXTENDS
```

creates a contract that extends another specified contract

> **Note:** the contract that extends will not be created

#### Examples

[](#examples)

```
php artisan make:contract ProductInterface
php artisan make:contract ProductInterface --extends=AdapterInterface
```

### make:class

[](#makeclass)

creates a class with the specified name. Using options you can create class with injected dependency and/or implementing the specified interface.

**Options**

```
-c, --contract[=CONTRACT]
```

If the name of the contract is specified, the command will create an interface with the specified name and a class that implements the created interface. Otherwise, a contract with the default name (classname + Interface) will be created and a class that implements the created interface.

```
-d, --dependency=DEPENDENCY
```

creates a class with the specified name and injects the specified dependency into the constructor.

```
--dependencyName=DEPENDENCYNAME
```

this option can only be used with the `dependency` option. Used if you want to name the injection dependency variable with a different name.

> **Note:** `dependency` and `dependencyName` will not create a dependency (class or interface). You should create it manually or using command.

#### Examples

[](#examples-1)

```
php artisan make:class Adapters/DocumentAdapter
php artisan make:class Adapters/DocumentAdapter -c
php artisan make:class Adapters/DocumentAdapter -c -dDocument
php artisan make:class Adapters/DocumentAdapter  --dependency=DocumentInterface --dependencyName=document
```

### make:repository

[](#makerepository)

creates a repository with the specified name. It also allows to extends base repository class, create and implement contract, inject the specified model.

**Options**

```
-e, --extends[=EXTENDS]
```

extends the specified class. If the name of the class to extend is not defined, it extends the base repository class that defined in package config.

```
-m, --model=MODEL
```

inject the model you specify. **Note**: the model will not be created, you should create it with appropriate command or manually.

```
-c, --contract
```

creates and implements the contract for the repository class

> All repositories will be placed in the directory `App\Repositories`. All contracts you can find in the folder `App\Contracts\Repositories`.

#### Examples

[](#examples-2)

```
php artisan make:repository ProductRepository
php artisan make:repository ProductRepository -c
php artisan make:repository ProductRepository -c -e
php artisan make:repository ProductRepository -c -e --model=Product
```

Base repository interface and class contain the next methods:

- get($columns = \['\*'\])
- find($id, array $columns = \['\*'\])
- findWhere(array $where, array $columns = \['\*'\])
- firstWhere(array $where, $columns = \['\*'\])
- create(array $attributes)
- update($id, array $attributes)
- updateWhere(array $where, array $attributes)
- delete($id)
- deleteWhere(array $where)

In addtition base repository class has magic `__call` method. So you can use any Eloquent model method you need.

### make:service

[](#makeservice)

creates service class in the `App\Services` folder. Also you can inject repository or model, extends base service class, implement contract.

**Options**

```
-e, --extends[=EXTENDS]
```

extends the specified class. If the name of the class to extend is not defined, it extends the base service class that defined in package config.

```
-r, --repository[=REPOSITORY]
```

injects repository class or interface.

```
-m, --model[=MODEL]
```

injects the specified model.

> **Notice**: you can use either the repository or the model, but not both options together.

```
-c, --contract
```

creates and implements the contract for the service class

#### Examples

[](#examples-3)

```
php artisan make:service ProductService
php artisan make:service ProductService --model=Product
php artisan make:service ProductService -c
php artisan make:service ProductService -c -e
php artisan make:service ProductService -c -e --repository=ProductRepository
```

### make:layered-bunch

[](#makelayered-bunch)

creates bunch of classes for layered structure. As the result the next ones will be created:

- model
- factory
- migration
- repository contract that extends base repository contract
- repository class that extends base repository class and implements the contract that was created on the previous step. Also model will be injected in this class
- service contract that extends base service contract
- service class that extends base service class and implements the contract created on the previous step. Also repository contract will be injected

> **Notice** this command only creates contracts and classes, but does not bind abstract to concrete implementation. You should do it manually in AppServiceProvider or other service provider!

#### Examples

[](#examples-4)

```
php artisan make:layered-bunch Product
```

### make:trait

[](#maketrait)

creates a trait with the specified name. There is no custom options for this command.

#### Examples

[](#examples-5)

```
php artisan make:trait Taggable
```

License
-------

[](#license)

laravel-layered is open-source package licensed under the MIT license

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2334d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26257193?v=4)[serhii-ivanenko](/maintainers/Serhii75)[@Serhii75](https://github.com/Serhii75)

---

Top Contributors

[![Serhii75](https://avatars.githubusercontent.com/u/26257193?v=4)](https://github.com/Serhii75 "Serhii75 (25 commits)")

---

Tags

laravel layered structurelaravel layered architecturelaravel service layerlaravel repository layer

### Embed Badge

![Health badge](/badges/si-dev-laravel-layered/health.svg)

```
[![Health](https://phpackages.com/badges/si-dev-laravel-layered/health.svg)](https://phpackages.com/packages/si-dev-laravel-layered)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
