Giter Site home page Giter Site logo

laravel-api-generator's Introduction

Hi there ๐Ÿ‘‹

I'm Mitul Golakiya. CEO & Founder of InfyOm Technologies (@infyomLabs). I'm a web developer and programmer by passion. I mostly work on backend and Laravel Apps. I'm the creator of various Laravel packages:

I also speak at multiple Laravel conferences. In my free time, I record videos on our Youtube Channel and write blogs about my learnings at InfyOm Blog.

I'm also one of the Admin of Laravel India Slack Community and actively answers questions there whenever possible.

I really enjoy working in Laravel and Open-source technologies. You can visit our company website Here and contact us there if you are interested in work with us. ๐Ÿ“ซ

If any of our packages are saving time for you and useful for you then you can help us by contributing to our OpenCollective. ๐Ÿ™

laravel-api-generator's People

Contributors

alvioleegia avatar anand-patel avatar darkaonline avatar ericlbarnes avatar gayanhewa avatar gildniy avatar jclyons52 avatar jonphipps avatar kivagant avatar mitulgolakiya avatar phillipmadsen avatar preshetin avatar santiagogg avatar thylo avatar wazirsoft avatar wink- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-api-generator's Issues

Enhancement - Inline documentation generation

Would be most awesome if you can add in inline documentation to help support tools like.

  • Swaggerevel
  • apiDocs

Having an instant API testing capability after a scaffold api would be a fantastic addition.

Contribution guidelines and issues in progress

It would be great to know what tasks are currently in progress and what can be picked up to fix/build. That way someone could contribute without worrying if work on a particular task has already started ?

Custom templates?

I'd like to be able to use my own templates or at least modify the included templates. Currently, since they reside in the vendor directory, it isn't feasible to edit those.

Is there a way to specify custom templates to be used?

More fields type

Could you help me to use more fields type in view form templates from Laravel 5.0. If is possible how can i use this to customize my application.
Thank you very much

any way to pass fields through CLI or file?

I really like your generator, but right now I am doing a lot of trial and error, figuring out how to make the most of your package by testing and regenerating.. testing the views and crud.. making tweaks to the generator and then re-running it. And it seems the only way to pass the fields and field options is one at a time via the interactive mode which is really cumbersome if using a lot of fields.

I would like to be able to pass it all on one line.. or to point the generator to a file containing the same parameters as what the inractive mode asks for. It could be in the exact same format.. as long as I don't have to re-type it manually every time. Is this already possible?

On a side note.. there's no way you could possibly generate api/scaffold by being passed an existing table and then iterating over the fields? Well at least if you could fulfill my first request.. it would be fairly easy to generate parameters from an existing schema.

Thanks for your work!!

trying to install dev-master but cannot resolve laracast-flash dev-master

Hi
I'm trying to install into a L5.1 app.

I've updated composer.json to include the repository and the package as described.

"mitulgolakiya/laravel-api-generator": "dev-master"

But when trying to do a composer update I get this error:

Problem 1
- Installation request for mitulgolakiya/laravel-api-generator dev-master -> satisfiable by mitulgolakiya/laravel-api-generator[dev-master].
- mitulgolakiya/laravel-api-generator dev-master requires laracasts/flash dev-master -> no matching package found.

Not clear what I should do now as unable to update the dependancy?

I can't finish the generator

I am creating a scaffold_api, but when I left blank to finish is still requiring a value, but I have finished to add values. It's a issue?

 Field::
 >

 [ERROR] A value is required.

 Field::
 >

I am working with last version: v1.3.3

php artisan route:list error

when running "php artisan route:list"

I get the following error:

[ReflectionException]
Class App\Http\Controllers\API\AuthController does not exist

It only happen to the API route, scaffold routes are not affected. Apart from that, everything works well!

Transform output data

Hello,

Is it possible to add an option to transform output api data......an transformer.......

Thanks for this cool package

Ask for repository

In the version for Laravel 5.1 the genereator does not ask if I want to use a repository or not, its posible to not use the repository?

route:cache cause api routes miss

route:cache cause api routes miss

config: generator.php

    'path_api_routes'          => app_path('Http/api_routes.php'),

routes.php:

Route::group(['prefix' => 'api', 'namespace' => 'API'], function ()
{
    Route::group(['prefix' => 'v1'], function ()
    {
        include_once Config::get('generator.path_api_routes');
    });
});

if i use php artisan route:cache
then run php artisan route:list
the include api routes not exists.

when i use php artisan route:clear
then run php artisan route:list
the include api routes show up again.

Some feature request

I love laravel but absolutely hate boilerplate coding , since i am a newbe and don't lnow much about artisan command , i was thinking about building a frontend like Gii for Yii with angular so that the boiler plate code can be autogenerated and then copied to respective folder , but you have saved a lot of my time , thanks ,

some feature that would be awesome
1.relationship , like: Post: hasMany Comment
2.seed file with faker types : body: fakertype : realtext
3.define input type in the view : body :textarea
4. some boilerplate for file / image uploading

error starting from scratch

hi Mitul,

i have a working project with your generator, suddenly between july 13 and today something got broken, i looked for an error on my code but didn't find anything.

finally i created a project from scratch following your steps and something is not working, some route.php error shows, in my working project have a similar issue, but with api routes

please help

rodrigo@jarvis:~/Projects > laravel new mitul
Crafting application...

php artisan clear-compiled
php artisan optimize
Generating optimized class loader
Compiling common classes
php artisan key:generate
Application key [p4PtFJu7G9tqCa89fbFK25MNTn5cM867] set successfully.
Application ready! Build something amazing.

rodrigo@jarvis:~/Projects > cd mitul/

rodrigo@jarvis:~/Projects/mitul > composer update

php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Removing league/flysystem (1.0.9)
  • Installing league/flysystem (1.0.10)
    Downloading: 100%
  • Removing laravel/framework (v5.1.7)
  • Installing laravel/framework (v5.1.8)
    Downloading: 100%
  • Installing bosnadev/repositories (dev-master 637c703)
    Loading from cache
  • Installing mitulgolakiya/laravel-api-generator (dev-master 6283290)
    Loading from cache
  • Installing laracasts/flash (dev-master 719af83)
    Cloning 719af83a720707bfbd7cf5a08e80158378bf5ecf
  • Installing laravelcollective/html (5.1.x-dev c93974c)
    Loading from cache

mitulgolakiya/laravel-api-generator suggests installing doctrine/dbal (Required to use generator from existing table.)
Writing lock file
Generating autoload files

php artisan optimize
Generating optimized class loader
Compiling common classes

rodrigo@jarvis:~/Projects/mitul > php artisan vendor:publish --provider="Mitul\Generator\GeneratorServiceProvider"

Copied File [/vendor/mitulgolakiya/laravel-api-generator/config/generator.php] To [/config/generator.php]
Publishing complete for tag []!

rodrigo@jarvis:~/Projects/mitul > php artisan mitul.generator:publish
common views published
/home/rodrigo/Projects/mitul/resources/views/common
api_routes.php generated
/home/rodrigo/Projects/mitul/app/Http/api_routes.php

[Illuminate\Contracts\Filesystem\FileNotFoundException]
/home/rodrigo/Projects/mitul/app/Http/routes.php

[League\Flysystem\FileNotFoundException]
File not found at path: home/rodrigo/Projects/mitul/app/Http/routes.php

Question

This is not really an issue but i could not find a place to add requests or possible features. I am trying to have your plugin make a few more things and tweek the routing a little bit and was wondering if you were up for helping.

Here is what im trying to do.
This currently builds this:
The artisan command can generate the following items:

  • Migration File
    • Model
    • Repository
    • Controller
    • View
      • index.blade.php
      • show.blade.php
      • create.blade.php
      • edit.blade.php
      • fields.blade.php
    • adjusts routes.php

But i am trying to make it do this:

  • Migration File
  • Model/Admin
  • Model
  • Repository
  • Controller
  • View (admin template)
    • - Admin/index.blade.php - Admin/show.blade.php - Admin/create.blade.php - Admin/edit.blade.php - Admin/fields.blade.php
  • View (frontend pubic site template)
    • - Frontend/live.blade.php
  • adjusts routes.php (for admin and live front end)

Do you have the time to help with this or can you give me some pointers that will make it easier. I am new to scaffold and will learn it if i have to.

Thanks for the awesome package you already created. now hopefully we can make it better.

What about 404 HTTP status?

Why API 'not found' has return http status code 200? Could you make a correct 404 http status?

GET /api/articles/BADID HTTP/1.1
...
< HTTP/1.1 200 OK
< Content-Type: application/json
{"flag":false,"message":"Article not found","code":1111}

P.S.: What does it mean '1111' code? Where I can find full list of this codes?

Thank you for excellent generator.

Please, give a chance to change 'laracasts/flash' dependency

laracasts/flash is not the only and not the best implementation of Flash.

For example, this package looks more clear, unlike laracasts variant.

Please, add into config/generator a special variable for choosing a flash-method call.
Of course, I can make a proxy-template and provider, but it's a dirty way.

Thank you.

Keep asking for fields

Hi,

Not sure if someone experience this issue.

I ran "php artisan mitul.generator:api Employee". The console asks for first field, I enter "name:string,255" and "required" for validation. The console asks for field again. At this point I want to finish my model so I left it blank and hit enter. But the console log doesn't let me enter. It keeps warning: "A value is required"
image

generate CRUD without create table

Hi
I already got tables in database. I don't won't to create tables from command line. and I have migration tables class inside database folder.
How to generate CRUD through command line ?

Thank you.

Add tags

Hello,

This package is great ! It saves me some time today. ๐Ÿ‘

Can you add some versions tag in order to have more stability.

Perhaps you can tag the last commit with v0.1.

Sincerly,

Arnaud

integration with sleeping-owl/admin

when I run the command:
php artisan mitul.generator:scaffold_api Post --fieldsFile="fields.json"
everything works!

but when i run:
php artisan route: list
I get this error:
root @ gateway: / var / www / htdocs / laranew # php artisan route: list

[ReflectionException]
Class App \ Http \ Controllers \ App \ Http \ Controllers \ API \ PostAPIController does not exist

What do I do wrong?
Is there a way to make an integration with sleeping-owl / admin and other ??
Tnks.

Error in generated Controller

Hi, I'm having the following error in a generated controller:

Cannot use Mitul\Controller\AppBaseController as Controller because the name is already in use

The line that leads to this error is:

use Mitul\Controller\AppBaseController as Controller;

View[app] not found

HI Mitul, great project thanks!
Just having an issue with: mitul.generator:scaffold_api
It generates everything ok but when i try load a view it seems to complain about missing app.
Assuming its referring to "@extends('app')" and that there is no app.blade, where am I meant to get this from, or what am I missing? Because if i just make a blank file with that name the error goes away but then the page loaded is blank.
Many thanks,
David

update to closed issue

#73 (comment)

Sorry you closed the issue before I finished trying what you said to try.

Here are the problems im having now.
1- I added the changes to the path and namespace in config like you said but they are not correcting the paths only adding the files into the proper place. so I get the placemenet of files im trying for but all the forms, routes and connections are wrong.

let me explain what im trying to do. I am trying to use your crud builder to generate my admin side for each section. I then have a front end , lets say live site for the public that I would also like to generate just index and view for but cannot figure out how to do this.

USERS EXAMPLE

Users

  • Migration File

  • Model

    • Admin\Model
  • Repository

  • Controller

    • Admin\AdminController

    (these are the main files generated but im trying to put them in a admin directory and have the paths still work .)

  • View\Admin\Users

    • 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

(need to generate these files that output the fields like show.blade.php does. nothing else no theme or anything. )

  • View\Users
    • index.blade.php
    • show.blade.php

Here is my config file with my edits per your solution.

'path_migration' => base_path('database/migrations/'),
'path_model' => app_path('Models**/Admin/'),
'path_repository' => app_path('Libraries/Repositories/'),
'path_controller' => app_path('Http/Controllers
/Admin/**'),
'path_api_controller' => app_path('Http/Controllers/API/'),
'path_views' => base_path('resources/views/admin/'),
'path_request' => app_path('Http/Requests/'),
'path_routes' => app_path('Http/Routes/admin_routes.php'),

(I added the routes directory to keep the route files easy to read and smaller. I am attaching the script I use in my routes file to make it happen. you might like it.)

'namespace_model' => 'App\Models*Admin_',
'namespace_repository' => 'App\Libraries\Repositories',
'namespace_controller' => 'App\Http\Controllers_Admin*',
'namespace_api_controller' => 'App\Http\Controllers\API',
'namespace_request' => 'App\Http\Requests',

My edit to routes.txt file

Route::get('admin/$MODEL_NAME_PLURAL_CAMEL$/{id}/delete', ['as' => 'admin.$MODEL_NAME_PLURAL_CAMEL$.delete', 'uses' => 'Admin\$MODEL_NAME$Controller@destroy', ]);

ROUTES FILE SWITCH SCRIPT.

foreach (new DirectoryIterator(__DIR__.'/Routes') as $file) { if (!$file->isDot() && !$file->isDir() && $file->getFilename() != '.gitignore') { require_once __DIR__.'/Routes/'.$file->getFilename(); } }
my-routes

This image is of my routes after I made the changes. Problem is they are not aligning with the output of the crud correctly.

ANY HELP WOULD BE APPRECIATED.

How to remove Request

Can I delete a Request file and straight to own validation in scaffold generator ?
Because in my opinion for a simple CRUD process i am not to use Request in order to code more simple. And may i to clone your repo and publish it with my style ?
Thanks.. :)

No Support for pagination

Its not hard to implement and most important features in listing items from DB.

Please add a support for this.

How To Create Custom Error Messages

Hay, I want to set own custom error messages on validation, for example rules required i want to set error to Do Not Blank.. etc.
How i do this ?
Thanks ..

Can not publish or generate

Hi @mitulgolakiya,

Why I can't publish or generate?

php artisan mitul.generator:publish

Result (routes.php not found)

common views published
/path/to/resources/views/common

api_routes.php generated
/path/to/app/Http/api_routes.php

[Illuminate\Contracts\Filesystem\FileNotFoundException]         
/path/to/app/Http/routes.php  

[League\Flysystem\FileNotFoundException]                                   
File not found at path: path/to/app/Http/routes.php                                                               

Note : Using Laravel v5.1.*

Make it easier

Get table name as param "php artisan mitul.generator:api TableName"
and take field name from there.
It will be much faster and easier for big tables.

Custom Format for the fields generator

Hi Mitul, first of all let me tell you thanks, for this package, is so helpfull, the second i try to customice the $FIELD_INPUT$ generators but i can't becouse no exist a file or template, can let me change this.

I try to change in your FormFieldsGenerator, but no is the good way, i create a Gist, i hope you can think in one solution for this.

Error when trying to generate with --search

Hi. Thanks for this nice generator.

I get this error when trying to generate with --search

FatalErrorException in cf9b4046a0ff5aa3cb467dff9252cd9f line 25:
syntax error, unexpected 'class' (T_CLASS), expecting ']'

I suppose the problem is coming from the code generated in indx.blade.php

Congratulations fro the nice work.

Michel.

publish asset command for export default templates

Hello.

Can you make a publish asset command for export default templates from /vendor/mitulgolakiya/laravel-api-generator/src/Mitul/Generator/Templates/ to /resources/api-generator-templates/ where developer can change some default things like this?:
@include('flash::message')

Thank you.

Application Namespace Error

I received the followinr error trying to generate a new API and scaffold:


php artisan mitul.generator:scaffold Avaliacao

  [RuntimeException]                       
  Unable to detect application namespace.  

What's wrong in this case?

Consider Dingo API features

The Dingo API package has a lot of features that this generator does not implement. Important features like versioning, rate limits, auth like oauth, internal requests and super flexible to override.
https://github.com/dingo/api/wiki

Would you consider implementing this package?

Publish Error

Hi, Mitul
I like this post and I would like to use this generator to get the better performance and to save my coding time.
I really appericiate for your post and sharing.
But when I publish the generator I got the following error, may be I would like to know the result.
I put the provider in app.php file.

{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Laracasts\Flash\FlashServiceProvider' not found","file":"C:\Users\pc14\Desktop\xampp\htdocs\test\vendor
\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php","line":158}}

Thanks In Advances,
Khaing.

Upgrade Documentation

Can you upgrade the documentation pleace, when i tried to use php artisan mitul.generator:publish templates not found, and i can fixed using this. php artisan mitul.generator:publish --templates

sendResponse should has encoding parameters

I think it will be much more convenient if you add some lines to the AppBaseController->sendResponse method allowing seeing encoded json properly:

public function sendResponse($result, $message)
{
    $headers = ['Content-type'=> 'application/json; charset=utf-8'];

    return Response::json($this->makeResponse($result, $message), 200, $headers, JSON_UNESCAPED_UNICODE);
}

Iโ€™d like to be able to easily read the output instead of "...\u043a\u0440\u044b\u043b\u0430\u0442\u044b\u0445 \u0444\u0440\u0430\u0437..."

package only works if app uses default name

I was just having trouble with another composer package which required me to rename my app to a different namespace.

And then I started having trouble with this package. It seems that because you use this statement in your controller

use App\Http\Controllers\Controller;

That this package will only work for applications that use the default namespace. I have renamed mine and the only way I could get your package to work was to rename that use statement and add my namespace.

This is the first time I am faced with such a conflict... is there something I am missing?

Generate Foreign

Hi mitul, i request you if can possible generate foreign in the generator of migrations like laravel 5 generators from laracast like this.

I using generator fields from file and my file look like this.

[
  {
    "field": "name:string",
    "type": "text",
    "validations": "required"
  },
  {
    "field": "department_id:integer:foreign",
    "type": "select",
    "validations": "required"
  }
]

Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.