kmlaravel/apis-generator

accelerate your work by building for you new api just a few clicks.

v1.1.0 2021-12-11 23:43 UTC

This package is auto-updated.

Last update: 2024-11-12 06:14:22 UTC


README

License Scrutinizer Code Quality Build Status Code Intelligence Status Code Quality

Notes

laravel 8 not supported yet !

APIs generator was developed for laravel 5.8+ to accelerate your work by building for your new api just a few clicks.

this package came with a base controller which helps to handle some logic and generate responses, we will develop all functions that help developers to reduce development time, simple interface to manage api creations process and view all api you had made before based on the credential JSON file.

What does this package build?

this package auto-build :

  • Model : with fill fillable properties depending on the values you chose.
  • Request : with validations rules and handle validation error message.
  • Controller : with full crud process based on the base controller.
  • Resource : to get resources data from the model.
  • Migration : with auto-generate for your database columns.

Features

  • Friendly simple interface to create your api with dark mode option using Darkmode.js.
  • Giving you the choice to choose what to build.
  • The large development space in the future update.

Installation

1 - Dependency

The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:

composer require kmlaravel/apis-generator
  • Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

3 - Copy the package providers to your local config with the publish command, this will publish asset and config :
php artisan vendor:publish --provider="KMLaravel\ApiGenerator\Providers\ApisGeneratorServiceProviders"
  • or you may publish asset and config separately.

3 - Copy the package config to your local config with the publish command:
php artisan vendor:publish --tag=apis-generator-config

In apis_generator.php configuration file you can determine the properties of the default values and some behaviors.

4 - Copy the package assets to your local resource views with the publish command:
php artisan vendor:publish --tag=apis-generator-asset

Basic usage

1 - Load your routes

As we said a little while ago we save your process result in resource/views/ApiGenerator/credential.josn this file contains an array that in turn contains objects each one contains controller class name, URL, api title, and type for your api.

to run this route we have to add this facade class in your routes/api.php file.

\KMLaravel\ApiGenerator\Facade\KMRoutesFacade::getRoutes();

now all your routes load automatically from routes in credential.json file.

2 - create your api

you should navigate to {{ your base url }}/apis-generator/create.

create_page

3 - view all api you have made

you can navigate to {{ your base url }}/apis-generator/index.

index_page

config options

add middleware to package routes

the initial package route middleware is web if you want to add any custom middleware you can do that by adding middleware keys in middleware arrays

    /*
    |--------------------------------------------------------------------------
    | package routes middleware
    |--------------------------------------------------------------------------
    |
    | this middleware array if you want to add custom middleware to package route,
    | this is applies to ( /apis-generator/index ) and ( /apis-generator/create ).
    |
    */
    //example
    "middleware" => [
        'admin',
    ],

add more database column types

you can do that by adding the type label to column_type array

    /*
    |--------------------------------------------------------------------------
    | types of the column in database which laravel provider.
    |--------------------------------------------------------------------------
    |
    | the options in database column select in creating a view,
    | you can add or optimize this column.
    |
    */
    "column_type" => [
        'text',
        'string',
        ...
    ],

Changelog

Please see the CHANGELOG for more information about what has changed or updated or added recently.

Security

If you discover any security related issues, please email them first to karam2mustafa@gmail.com, if we do not fix it within a short period of time please open a new issue describing your problem.

Credits

karam mustafa