PHPackages                             hamzaouaghad/multilayering - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hamzaouaghad/multilayering

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hamzaouaghad/multilayering
==========================

A tiny laravel package to speed up the workflow with the multilayering convetion

0.1.1(10y ago)339MITPHPPHP &gt;=5.3.0

Since Aug 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/HOuaghad/multilayering)[ Packagist](https://packagist.org/packages/hamzaouaghad/multilayering)[ Docs](https://github.com/HOuaghad/multilayering)[ RSS](/packages/hamzaouaghad-multilayering/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Multilayering
=============

[](#multilayering)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

This package is a tiny laravel package that generates artisan commands to generate the multilayer conventions faster, and speed up the workflow.

If you don't know what multilayer is , feel free to have quick read at [coderwall](https://coderwall.com/p/itnqyq/alternatives-to-hmvc-with-laravel)

Install
-------

[](#install)

Via Composer

```
$ composer require hamzaouaghad/multilayering
```

Usage
-----

[](#usage)

Make sure you add this line in your `Config\app.php`

```
 'providers' => [

 Hamzaouaghad\Multilayering\MultilayerGeneratorServiceProvider::class,
 Hamzaouaghad\Multilayering\RegisterCommandsServiceProvider::class,

 ],
```

save and run

```
 $ composer dumpautoload -o
 $ php artisan vendor:publish
```

Now to go your 'app/providers/', you will find a new providers added :

`MultilayerGeneratorServiceProvider`

If it's your first time, and you still need to generate the new folder structure, please run:

```
php artisan make:multilayer
```

And afterwards, again, add this to your providers:

```
App\Providers\MultilayerGeneratorServiceProvider`.
```

Again,

```
$ composer dumpautoload -o
$ php artisan vendor:publish
```

I could easily automate the process of adding all of these service providers and calling them for you, however, this is never the best approach, if not a bad practice, as adding them manually -unlinke automatic registering- actually keeps track of all of the service providers you are using, in your providers array.

So bare the pain of keeping your work organized, it's worth it.

If you wish to quicken the paste, and bake all, you may use the following command :

```
php artisan bake:all ClassName
```

This command will generate an eloquent class, an interface for it, and a repository that uses this interface. Also, at the http layer, it generates a motor for it that injects that repository.

If you may to bake all with specifics, you may use the following options:

```
--interface : The name of the interface to be created for our calss
--motor : the name of the motor to be created for our class
--trait : the name of the trait that your motor maye use
--repository : the name of the repository that this class would be covered under.
```

After each file generation, you'll have to run

```
$ php artisan vendor:publish
```

As it will mention to you everytime, so I think you won't forget.

\##Examples

```
php artisan bake:all User --repository=Accounts --interface=Security --motor=STAFF --trait=Authentication
```

This will create :

```
class User extends Eloquent
```

and

```
interface SecurityInterface
```

and

```
class AccountsRepository implements SecurityInterface
```

and

```
class STAFFmotor extends Motor
{
 public function __construct(AccountsRepository $repo)
 {
    $this->repository = $repo;
 }

 use /Authentication;
}
```

After all of this, the `Providers\MultilayerGeneratorServiceProvider` will be updated as follows :

```
class MultilayerGeneratorServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->booting(function(){
            $loader = \Illuminate\Foundation\AliasLoader::getInstance();
        /*
         |
         | Repositories Classes
         |
         */

             $loader->alias('AccountsRepository', 'App\DataLayer\Repositories\AccountsRepository');
             $loader->alias('AccountsRepoInterface', 'AccountsRepository');

        /*
         |
         | Object Classes
         |
         */

             $loader->alias('User', 'App\DataLayer\Objects\User');

        /*
         |
         | Traits
         |
         */
            $loader->alias('CRUDtrait', 'App\Http\Traits\CRUDtrait');//don't modify this.
            $loader->alias('AuthenticationTrait', 'App\Http\Traits\AuthenticationTrait');

        /*
         |
         | Motors
         |
         */

            $loader->alias('Motor', 'App\Http\Motors\Motor');
            $loader->alias('STAFFmotor', 'App\Http\Controllers\Motors\STAFFmotor');
        });
    }
}
```

Available commands

```
 bake
  bake:all                   Creates an eloquent class, an interface and a repository for it, also a motor, and a trait if specified.
  bake:datalayer             Bake the data layer for the given class
 make
  make:controller            Create a new resource controller class
  make:datalayer             Creates the datalayer directory structure
  make:datalayer:class       Creates an eloquent class, its interface and its repository.
  make:datalayer:interface   Creates an interface.
  make:datalayer:repository  Creates a repository
  make:httplayer             Creates the httplayer directory structure
  make:httplayer:basemotor   Creates an abstract motor class for inheritence.
  make:httplayer:motor       Creates a motor, with the injected specified repository, and the trait to be used.
  make:httplayer:trait
  make:multilayer            This command generates the directory structure for the multilayering conventions.

```

If you wish to go your own way, without mass baking, you can use the following

```
php artisan make:datalayer:class

php artisan make:datalayer:interface

php artisan make:datalayer:repository  (with options: --interface= the one you wish your repo to implement, --class=The class whose repo is this

php artisan make:httplayer:motor   --trait= : The trait that is desired to be used --repository= : A specific repository to be implemented

php artisan make:httplayer:trait
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Hamza Ouaghad](https://twitter.com/hamza_ouaghad)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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

3932d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d56756b5b07912a6cf1ed3d6fbe2bfdc19ba17befac7ee9adf076f74dfe74cef?d=identicon)[HOuaghad](/maintainers/HOuaghad)

---

Top Contributors

[![derrandz](https://avatars.githubusercontent.com/u/13497307?v=4)](https://github.com/derrandz "derrandz (1 commits)")

---

Tags

conventionsdesign-patternshmvclaravelmultiversemvcphpproducvityqualitylaravelLayersHamzaOuaghadhamzaouaghadmultilayeringseperation-of-concernssoc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hamzaouaghad-multilayering/health.svg)

```
[![Health](https://phpackages.com/badges/hamzaouaghad-multilayering/health.svg)](https://phpackages.com/packages/hamzaouaghad-multilayering)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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