2017 © Pedro Peláez
 

library multilayering

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

image

hamzaouaghad/multilayering

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

  • Thursday, January 28, 2016
  • by HOuaghad
  • Repository
  • 1 Watchers
  • 2 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Multilayering

![Software License][ico-license], (*1)

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

If you don't know what multilayer is , feel free to have quick read at coderwall, (*3)

Install

Via Composer, (*4)

``` bash $ composer require hamzaouaghad/multilayering, (*5)


## Usage Make sure you add this line in your `Config\app.php` ``` php 'providers' => [ Hamzaouaghad\Multilayering\MultilayerGeneratorServiceProvider::class, Hamzaouaghad\Multilayering\RegisterCommandsServiceProvider::class, ],

save and run, (*6)

 $ 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:

 ```bash
 php artisan make:multilayer
 ```

 And afterwards, again, add this to your providers:
 ```php
 App\Providers\MultilayerGeneratorServiceProvider`.

Again,, (*7)

$ 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., (*8)

So bare the pain of keeping your work organized, it's worth it., (*9)

If you wish to quicken the paste, and bake all, you may use the following command : bash 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., (*10)

If you may to bake all with specifics, you may use the following options:, (*11)

--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, (*12)


$ php artisan vendor:publish

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

Examples

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

This will create :, (*14)

class User extends Eloquent

and, (*15)

interface SecurityInterface

and, (*16)

class AccountsRepository implements SecurityInterface

and, (*17)

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 :, (*18)


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, (*19)


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, (*20)

php artisan make:datalayer:class <name>

php artisan make:datalayer:interface <name>

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

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

php artisan make:httplayer:trait <name>

Contributing

Please see CONTRIBUTING for details., (*21)

Security

If you discover any security related issues, please email ouaghad.hamza@gmail.com instead of using the issue tracker., (*22)

Credits

License

The MIT License (MIT). Please see License File for more information., (*23)

The Versions

28/01 2016

dev-master

9999999-dev https://github.com/HOuaghad/multilayering

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hamza Ouaghad

laravel layers hamzaouaghad multilayering seperation-of-concerns soc hamza ouaghad

12/08 2015

0.1.1

0.1.1.0 https://github.com/HOuaghad/multilayering

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hamza Ouaghad

laravel layers hamzaouaghad multilayering seperation-of-concerns soc hamza ouaghad

11/08 2015

0.1

0.1.0.0 https://github.com/HOuaghad/multilayering

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hamza Ouaghad

laravel layers hamzaouaghad multilayering seperation-of-concerns soc hamza ouaghad