2017 © Pedro Peláez

library quick-gen

A laravel generators package.



A laravel generators package.

  • Friday, February 10, 2017
  • by joshralph93
  • Repository
  • 1 Watchers
  • 0 Stars
  • 186 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown


(Work in progress)

Only currently actively tested with Laravel 5.4. Previous version support to come..., (*1)

Contribution welcome., (*2)


Pull in the package using composer, (*3)

$ composer require joshralph/quick-gen "dev-master" --dev

Include the service provider within /config/app.php, (*4)


Getting Started

You will need to run the command below to publish the stub files that ship with the package., (*5)

php artisan vendor:publish --tag=stubs

To run the generator run the below command. The example resource name given below should be replaced as you need., (*6)

php artisan quick-gen:generate cars


The package ships with a standard CRUD template that you can use to generate basic CRUD functionality., (*7)

To specify which template you wish to use, add the template flag to the command., (*8)

crud (default)

This template will generate the following files for you within the standard laravel directory structure:, (*9)

  • Controller
  • Model
  • Views
    • index.blade.php
    • create.blade.php
    • edit.blade.php
    • partials/list.blade.php
    • partials/form.blade.php

Custom Templates

Of course you will likely want to create your own template files that are in keeping with your current view structure, and coding style., (*10)

To create a new template simply create a new folder within the resources/stubs/ directory. The folder name should be used when setting the --template argument., (*11)

You can then call the command below using the --template argument, (*12)

php artisan quick-gen:generate cars --template=my-template

Stub Syntax

Note all stub files should end in .stub, (*13)


The following variables are made available to stub files (both content and filename):, (*14)

name - The name of the resource as specified in the generate command, (*15)

baseNamespace - The namespace where the generated files will reside., (*16)

...and should be wrapped in the following way:, (*17)

Stub Contents, (*18)

namespace <<baseNamespace>>\Http\Controllers\Admin;

Filename, (*19)



You may wish to transform the case and formatting of variables within stub files. These can be used both within the file contents and the filename., (*20)

Filters can be added to variables using a . delimiter., (*21)

@foreach ($<<name.camel.plural>> as $<<name.camel.singular>>)
        <td>{{ $<<name.camel.singular>>->name }}</td>

The following filters are available:, (*22)

camel - convert the variable to camel case., (*23)

studly - convert the variable to studly case., (*24)

snake - convert the variable to snake case., (*25)

plural - convert the variable to plural., (*26)

singular - convert the variable to singular., (*27)

lower - convert the variable to lowercase., (*28)

ucwords - upper case the first letter of each word in the variable (see words)., (*29)

words - convert the variable to space delimited words, (*30)


  • The default template doesn't currently update routes files. These will need to be mapped manually:
Verb Name Method
GET <<name.snake.plural>>.index @index
GET <<name.snake.plural>>.create @create
POST <<name.snake.plural>>.store @store
GET <<name.snake.plural>>.edit @edit($id)
POST <<name.snake.plural>>.update @update($id)
GET <<name.snake.plural>>.destroy @destroy($id)

The Versions

10/02 2017



A laravel generators package.

  Sources   Download

by Josh Ralph