chihchenghuang/laravel-mrs-generators

This package is a experimental project inspired by yish/generators which extends the core file generators based on Laravel 5. It can help you build classes with basic Model-Repository-Service pattern.
24
Install
composer require chihchenghuang/laravel-mrs-generators
Latest Version:0.1.2
PHP:>=5.6.4
License:MIT
Last Updated:Sep 7, 2017
Links: GitHub  ·  Packagist
Maintainer: chihchenghuang

Laravel MRS Generators

This package is a experimental project inspired by yish/generators which extends the core file generators based on Laravel 5 It can help you build classes with basic Model-Repository-Service pattern.

Installation

Install by composer

    $ composer require chihchenghuang/laravel-mrs-generators

Registing Service Provider

<?php

//app.php

'providers' => [
        
        /*
         * Laravel MRS Generators Service Provider
         */
        \ChihCheng\MRSGenerators\GeneratorsServiceProvider::class,

    ],

or

<?php

//app/Providers/AppServiceProvider.php

    public function register()
    {
        if ($this->app->environment() == 'local')
        {
	        /*
	         * Laravel MRS Generators Service Provider
	         */
            $this->app->register( \ChihCheng\MRSGenerators\GeneratorsServiceProvider::class );

        }
    }

Example

Generate Repository:

This command will generate a repository class.

    $ php artisan make:repository Repositories/TestRepository

Generate Service:

This command will generate a service class.

    $ php artisan make:repository Services/TestService

Generate classes based on the corresponding Model-Repository-Service Pattern Set:

This command will generate classes based on the corresponding Model-Repository-Service Pattern Set. It will create files like the example pattern below by using only one command:

    $ php artisan make:mrs-model Test
  • app/Models/Test.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Test extends Model
{
    //
}

  • app/Repositories/TestRepository.php
<?php

namespace App\Repositories;

use App\Models\Test;

class TestRepository
{
    protected $test;

    public function __construct( Test $test )
    {
        $this->test = $test;
    }

}

  • app/Services/TestService.php
<?php

namespace App\Services;

use App\Repositories\TestRepository;

class TestService
{
    protected $testRepository;

    public function __construct( TestRepository $testRepository )
    {
        $this->testRepository = $testRepository;
    }

}

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

628,058,007 9,707
laravel/framework

The Laravel Framework.

572,249,171 34,893
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440