GrafiteInc / CrudMaker

An incredibly powerful and some say magical CRUD maker for Laravel
MIT License
30 stars 19 forks source link

Lumen full compatibility, Filesystem Exception on CRUD generation #12

Closed breakingrobot closed 8 years ago

breakingrobot commented 8 years ago

See #11

Also, we can't use --api argument without ApiController.txt or ApiRoutes.txt, as the main purpose of Lumen is to create webservices and API we should add these as separated files (like Laravel files) and disable some arguments for Lumen or have a way to implements them all.

casperboone commented 8 years ago

You could just use the main controller / routes template, make them suitable for your api, and not append --api, right?

breakingrobot commented 8 years ago

@casperboone not using --api create basic Routes using the route_suffix and route_prefix and also the API Controller are not namespaced as API.

Also, if you don't use --api --serviceOnly both API and non-API controller will be created, and Lumen template don't include API templates at all (and they should), it'll return you a looping dump (a debug artefact) and if you're not using PHP 7 a fatal error (not FatalThrowableException).

The package should manage the separation between API and non-API for Lumen as it does for Laravel, it's just adding some templates adapted for Lumen, also haven't tested the Facade generator on Lumen for now..

casperboone commented 8 years ago

@breakingrobot

not using --api create basic Routes using the route_suffix and route_prefix and also the API Controller are not namespaced as API.

You can fix both in the templates, right?

Also, if you don't use --api --serviceOnly both API and non-API controller will be created, and Lumen template don't include API templates at all (and they should), it'll return you a looping dump (a debug artefact) and if you're not using PHP 7 a fatal error (not FatalThrowableException).

Since you will not be creating anything other than API stuff, appending --api does not really have a meaning (and should do the same as not appending it). Therefore just replacing your Routes and Controller template with the ApiRoutes and ApiController template, is fine I guess. Maybe it's better to just make sure it works without the api templates.

Haven't used CrudMaker in Lumen myself, so maybe I'm saying weird stuff

casperboone commented 8 years ago

Oh, I see I was basically describing the templates as they currently are.

Then I would say we just need to ignore the --api flag in code when using Lumen, and everything will be fine. Or am I missing something here?

breakingrobot commented 8 years ago

@casperboone

As now, you can't generate views on Lumen, as you can't generate Controller and Api\Controller, you can actually only generate Controller, I've no problem changing it and use only API but someone who use Lumen for minimal web applications and web services may need both, fixing the lack of template for Lumen could be great ;)

casperboone commented 8 years ago

@breakingrobot Ah, I get your point now. Didn't know you actually wanted to create an UI. In that case you could just add views and a separate ApiController / ApiRoutes file yourself, right? I think by default only generating API stuff in Lumen is better. If someone wants to, it is not that hard to just add the files to your template directory.

breakingrobot commented 8 years ago

@casperboone Shouldn't it be implemented by default on the package as it is for Laravel ?

(By default, non-api (non-namespaced) stuff is generated using crudmaker:table ou crudmaker:new without --api)

casperboone commented 8 years ago

@breakingrobot I don't think so, most people using Lumen are building small API only applications. But that's just my opinion, let's see what @mlantz thinks ;)

breakingrobot commented 8 years ago

@casperboone So if we assume that, merging #11 will rename Controller.txt and Routes.txt to ApiController.txt and ApiRoutes.txt, and we should add a specific part in the documentation to use --api --serviceOnly for Lumen and if they need to create base Controller and Routes with views, they should add templates on their own ?

casperboone commented 8 years ago

@breakingrobot I would stay just stick with the current templates, so you do not have to use any flags by default.

If a users wants to they can rename Controller.txt and Routes.txt to ApiController.txt and ApiRoutes.txt, and add a new Controller.txt, Routes.txt and some views. It might be good to explain that in the docs though.

breakingrobot commented 8 years ago

@casperboone meaning that all our API would be under App\Http\Controllers namespace and routes_prefix and routes_suffix will be applied, meaning that users should change crudmaker.php or their template to implement a specific API namespace etc..

casperboone commented 8 years ago

@breakingrobot That's exactly what you want when you're only creating an API. In case you want to add an UI part to your application as well, and use the separate API templates, the files will be put in app/Http/Controller/Api and you change the namespace to App\Http\Controller\Api in the template file yourself.

mlantz commented 8 years ago

I'm far more prone to leaving Lumen support as API only, and updating the docs accordingly. Also specifying which options are compatible with which framework. The fact that the default Lumen structure has removed views completely from the system is an indication that they are not that Lumen CRUDs should be API only. I only support the idea that Lumen be used for simple API structures, nothing more personally. As such I'll update accordingly. Thanks for the thoughts on this guys :)