PHPackages                             gabrieljaime/laravel-api-generator-gj - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. gabrieljaime/laravel-api-generator-gj

ActiveLibrary[API Development](/categories/api)

gabrieljaime/laravel-api-generator-gj
=====================================

Laravel API/Scaffold/CRUD Generator from just one command with including Controller, Repository, Model, Migrations, routes.php update.

021PHP

Since Feb 8Pushed 10y ago1 watchersCompare

[ Source](https://github.com/gabrieljaime/laravel-api-generator-for-lteTemplate)[ Packagist](https://packagist.org/packages/gabrieljaime/laravel-api-generator-gj)[ RSS](/packages/gabrieljaime-laravel-api-generator-gj/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel API/Scaffold/CRUD Generator (Laravel5.1) for gabrieljaime/laravel-admin-master
======================================================================================

[](#laravel-apiscaffoldcrud-generator-laravel51-for--gabrieljaimelaravel-admin-master)

I enjoy creating API's and I have worked on many projects that required them. But the problem I always faced was setting up all the boilerplate code. For example each end point needs a migration, model, controller, repository, and on and on. I wanted a way to streamline this process and that is how this package was born.

This API generator allows you to use artisan commands to automatically generate all these files saving you time. Not only does it auto generate the files but it will set the namespaces.

The artisan command can generate the following items:

- Migration File
- Model
- Repository
- Controller
- View
    - index.blade.php
    - table.blade.php
    - show.blade.php
    - show\_fields.blade.php
    - create.blade.php
    - edit.blade.php
    - fields.blade.php
- adjusts routes.php

And your simple CRUD and APIs are ready in mere seconds.

Documentation is in process...
==============================

[](#documentation-is-in-process)

Documentation
-------------

[](#documentation)

1. [Installation](#installation)
2. [Configuration](#configuration)
3. [Publish &amp; Initialization](#publish--initialization)
4. [Generator](#generator)
5. [Supported Field Types](#supported-field-types)
6. [Customization](#customization)
    1. [Base Controller](#base-controller)
    2. [Customize Templates](#customize-templates)
    3. [Dingo API Integration](#dingo-api-integration)
7. [Options](#options)
    1. [Paginate Records](#paginate-records)
    2. [Model Soft Deletes](#model-soft-deletes)
    3. [Fields From File](#fields-from-file)
    4. [Custom Table Name](#custom-table-name)
    5. [Skip Migration](#skip-migration)
    6. [Remember Token](#remember-token)
8. [Generator from existing tables](#generator-from-existing-tables)

Installation
------------

[](#installation)

1. Add this package to your composer.json:

    ```
     "repositories": [
         {
             "type": "git",
             "url": "https://github.com/mitulgolakiya/laracast-flash"
         }
     ],
     "require": {
         "laracasts/flash": "dev-master",
         "laravelcollective/html": "5.1.*@dev",
         "bosnadev/repositories": "dev-master",
         "gabrieljaime/laravel-api-generator-gj": "dev-master"
     }

    ```
2. Run composer update

    ```
     composer update

    ```
3. Add the ServiceProviders to the providers array in `config/app.php`.
    As we are using these two packages [laravelcollective/html](https://github.com/LaravelCollective/html) &amp; [laracasts/flash](https://github.com/laracasts/flash) as a dependency.
    so we need to add those ServiceProviders as well.

    ```
     Collective\Html\HtmlServiceProvider::class,
     Laracasts\Flash\FlashServiceProvider::class,
     Gabo\Generator\GeneratorServiceProvider::class,

    ```

    Also for convenience, add these facades in alias array in `config/app.php`.

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

    ```

Configuration
-------------

[](#configuration)

Publish Configuration file `generator.php`.

```
    php artisan vendor:publish --provider="Gabo\Generator\GeneratorServiceProvider"

```

Config file (`config/generator.php`) contains path for all generated files

`base_controller` - Base Controller for all Controllers

`path_migration` - Path where Migration file to be generated
`path_model` - Path where Model file to be generated
`path_repository` - Path where Repository file to be generated
`path_controller` - Path where Controller file to be generated
`path_api_controller` - Path where API Controller file to be generated
`path_views` - Path where views will be created
`path_request` - Path where request file will be created
`path_routes` - Path of routes.php (if you are using any custom routes file)
`path_api_routes` - Path of api\_routes.php (this file will contain all api routes)

`namespace_model` - Namespace of Model
`namespace_repository` - Namespace of Repository
`namespace_controller` - Namespace of Controller
`namespace_api_controller` - Namespace of API Controller
`namespace_request` - Namespace for Request

`model_extend_class` - Extend class of Models

`api_prefix` - API Prefix `api_version` - API Version

`use_dingo_api` - Integrate APIs with dingo/api package

Publish &amp; Initialization
----------------------------

[](#publish--initialization)

Mainly, we need to do three basic things to get started.

1. Publish some common views like `errors.blade.php` &amp; `paginate.blade.php`.
2. Publish `api_routes.php` which will contain all our api routes.
3. Init `routes.php` for api routes. We need to include `api_routes.php` into main `routes.php`.

    ```
     php artisan gabo.generator:publish

    ```

Generator
---------

[](#generator)

Fire artisan command to generate API, Scaffold with CRUD views or both API as well as CRUD views.

Generate API:

```
    php artisan gabo.generator:api ModelName

```

Generate CRUD Scaffold:

```
    php artisan gabo.generator:scaffold ModelName

```

Generate CRUD Scaffold with API:

```
    php artisan gabo.generator:scaffold_api ModelName

```

e.g.

```
php artisan gabo.generator:api Project
php artisan gabo.generator:api Post

php artisan gabo.generator:scaffold Project
php artisan gabo.generator:scaffold Post

php artisan gabo.generator:scaffold_api Project
php artisan gabo.generator:scaffold_api Post

```

Supported HTML Field Types
--------------------------

[](#supported-html-field-types)

Here is the list of supported field types with options:

- text
- textarea
- password
- email
- file
- checkbox
- radio:male,female,option3,option4
- number
- date
- select:India,USA

Customization
-------------

[](#customization)

### Base Controller

[](#base-controller)

If you want to use your own base controller or want to extend/modify default AppBaseController then you can have following options:

1. If you want to use another controller (recommended to extends AppBaseController with new controller) as base controller then modify `base_controller` value in `config/generator.php`
2. If you want to modify AppBaseController then,

    1. Publish AppBaseController in your controllers path

        php artisan gabo.generator:publish --baseController
    2. Modify the content of `AppBaseController.php` and set it as a `base_controller` in `config/generator.php`

### Customize Templates

[](#customize-templates)

To use your own custom templates,

1. Publish templates to `/resources/api-generator-templates`

    ```
     php artisan gabo.generator:publish --templates

    ```
2. Leave only those templates that you want to change. Remove the templates that do not plan to change.

Options
-------

[](#options)

### Paginate Records

[](#paginate-records)

To paginate records, you can specify paginate option, e.g.

```
    php artisan gabo.generator:api Post --paginate=10

```

### Model Soft Deletes

[](#model-soft-deletes)

To use SoftDelete, use softDelete option,

```
    php artisan gabo.generator:api Post --softDelete

```

### Fields From File

[](#fields-from-file)

If you want to pass fields from file then you can create fields json file and pass it via command line. Here is the sample [fields.json](https://github.com/mitulgolakiya/laravel-api-generator/blob/master/samples/fields.json)

You have to pass option `--fieldsFile=absolute_file_path_or_path_from_base_directory` with command. e.g.

```
     php artisan gabo.generator:scaffold_api Post --fieldsFile="/Users/Gabo/laravel-api-generator-for-lteTemplate/fields.json"
     php artisan gabo.generator:scaffold_api Post --fieldsFile="fields.json"

```

### Custom Table Name

[](#custom-table-name)

You can also specify your own custom table name by,

```
    php artisan gabo.generator:api Post --tableName=custom_table_name

```

### Skip Migration

[](#skip-migration)

You can also skip migration generation,

```
    php artisan gabo.generator:api Post --skipMigration

```

### Remember Token

[](#remember-token)

To generate rememberToken field in migration file,

```
    php artisan gabo.generator:api Post --rememberToken

```

Generator from existing tables
------------------------------

[](#generator-from-existing-tables)

To use generator with existing table, you can specify `--fromTable` option. `--tableName` option is required and you need to specify table name.

Just make sure, you have installed `doctrine/dbal` package.

**Limitation:** As of now it is not fully working (work is in progress). It will not create migration file. You need to tweak some of the things in your generated files like timestamps, primary key etc.

```
    php artisan gabo.generator:api Post --fromTable --tableName=posts

```

Credits
-------

[](#credits)

This API Generator is inspired on [Mitul Golakiya](https://github.com/mitulgolakiya). And it was amended by [Gabriel Jaime](https://github.com/gabrieljaime) to suit the environment in

**Bugs &amp; Forks are welcomed :)**

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec85efdf7b252ec9cc88b5d32c9b75de7c1ba1318c6cebc9dc11d3b7b8f15e12?d=identicon)[GabrielJaime](/maintainers/GabrielJaime)

---

Top Contributors

[![gabrieljaime](https://avatars.githubusercontent.com/u/11546752?v=4)](https://github.com/gabrieljaime "gabrieljaime (9 commits)")

### Embed Badge

![Health badge](/badges/gabrieljaime-laravel-api-generator-gj/health.svg)

```
[![Health](https://phpackages.com/badges/gabrieljaime-laravel-api-generator-gj/health.svg)](https://phpackages.com/packages/gabrieljaime-laravel-api-generator-gj)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
