anik/repository-generator

Repository generator generates repository classes as it requires for repottern package.

1.0.0 2016-07-07 11:05 UTC

README

Repository generator generates the Repository class that's how it's required for the Repottern. Have a look at repottern

Requirements:

  • Laravel >= 5
  • PHP >= 5.5

How to install?

  1. composer require anik/repository-generator
  2. Add Anik\Generator\Providers\RepositoryGeneratorServiceProvider::class to the providers array in config/app.php
  3. After the installation, run php artisan vendor:publish. This will copy the config file to Laravel's config directory named generator.php

Configuration:

  1. namespace: The namespace you want to have for the class.
  2. dir: The path the file will be saved
  3. model_namespace: The model namespace, if you want to return from the class on the fly. Don't append any slash.

Usages:

The artisan console has one mandatory argument and 3 optional arguments.

  • Mandatory argument
    1. Class name: The class name you want as a repository. Must be a valid identifier.
  • Optional arguments
    1. --dir=dir_name. if specified, the new class will be created on that directory.
    2. --namespace=namespace. if specified, then class will have that namespace.
    3. --model=model. if specified, will lookup using the config file's model_namespace. If found, then will be returned from the implemented model() method. Otherwise, will be left blank.

Example:

php artisan make:repository UserRepository
php artisan make:repository UserRepository --namespace=Repository
php artisan make:repository UserRepository --model=User
php artisan make:repository UserRepository --namespace=Repository --model=User

Note:

Here, the optional arguments can be used at any position

If the --dir argument is specified, then the directory will be created regarding the current path

License:

Repository Generator is released under the MIT Licence.

Bugs and Issues:

Well, I'll always appreciate if you find any bug or issue. Feel free to inform. Anyway, forks are welcomed too.