Skip to content

Installation ​

Add Packages ​

Check the following table for Laravel version compatibility,

Laravel Versioninfyomlabs/laravel-generatorlaravelcollective/htmlinfyomlabs/adminlte-templates
6.0^1.0^6.0^3.0
7.0^2.0^6.1^3.0
8.0^3.0^6.2^3.0

Add following packages into composer.json while using it with Laravel 7.

sh
"require": {
       "infyomlabs/laravel-generator": "^2.0",
       "laravelcollective/html": "^6.1",
       "infyomlabs/adminlte-templates": "^3.0"
}

If you want to use CoreUI then install coreui-templates instead of adminlte-templates.

If you want to use Generate from Table option, you need to install,

sh
"require": {
       "doctrine/dbal": "~2.3"
}

Composer Update ​

After adding packages, run the following command:

composer update

Add Aliases ​

Add following alias to aliases array in config/app.php

sh
'Form'      => Collective\Html\FormFacade::class,
'Html'      => Collective\Html\HtmlFacade::class,
'Flash'     => Laracasts\Flash\Flash::class,

Publish Vendor ​

Run the following command:

php artisan vendor:publish

Update API Routes ​

Open app\Providers\RouteServiceProvider.php and update mapApiRoutes method as following:

sh
Route::prefix('api/v1')
    ->middleware('api')
    ->as('api.')
    ->namespace($this->namespace."\\API")
    ->group(base_path('routes/api.php'));

We have added as prefix to separate out named routes of api and web. Also its a better way to store api controllers in separate directory with separate namespace. so we have added "\\API" suffix in namespace.

Customize Configuration (optional) ​

If you have tweaked any paths or laravel settings like custom namespace, rather than regular laravel installation, check out this page and configure the generator based on your settings

Publish Command ​

Publish generator stuff:

php artisan infyom:publish

By publishing API stuff, it will create following files:

sh
|- app - app directory
    |- Http - Http directory
        |- Controllers - Controllers directory
           |- AppBaseController.php - New base controller which will be used as a base class for each controller
    |-  Repositories - Repositories directory
        |- BaseRepository.php - BaseRepository for all repository files
|- tests - tests directory
    |- ApiTestTrait.php - Api test trait to be used for testing
    |- Traits - directory to store created traits of models
    |- APIs - directory to store APIs tested cases
    |- Repositories - directory to store Repository tested cases

Recommended: If you have a fresh new laravel application and want a basic admin panel layout with adminlte admin panel, then you can use [Publish Layout Command](/laravelgenerator/docs/7.0/publish-layout).

Now we are all set to get started with the generator.