I'm going to create an API for a new project. I have done trial and error before, but honestly APIs gets messy fast and hard to refactor without breaking a lot of stuff.
I am doing RESTful but besides that I don't have any guidelines for myself. Which packages for Laravel would you recommend me to create a better streamlined flow or which advices do you have?
If you are new to laravel then i think i can suggest this link : itsolutionstuff.com/post/how-to-create-rest-api-i… for create api, i think this is better because in that link i see it's create basic coman function for success and error response. You can do it simply RESTFul API with laravel 5.5 app.
Thanks :)
Hey Emil,
I run codeburst.io and we have 7 tutorials on Laravel API's that you might consider checking out for motivation and/or ideas (free):
I would strongly recommend Dingo API package github.com/dingo/api
We've build full api for our project within 1 day thanks to that package github.com/akaunting/akaunting
Although this isn't a very popular opinion, I've found Lumen to be really great to build an API with.
It's very light and I haven't come up against any problems when trying to create a fairly complex API. There's nothing in there that I've thought "Oh damn! We should be using a full-blown Laravel installation."
Admittedly, it is missing a couple of features that you might be used to if you're familiar with Laravel, but if you don't mind simplifying/separating some stuff out (i.e. OAuth in a separate service OR just using API keys, for example) and writing a little bit of piping, you can achieve great things.
The performance of Lumen is great for our needs and we've managed to create a really flexible and efficient API with it that conforms to the JSON-API standard, uses OAuth for access delegation and much more, without tying us to a particular package.
I'd be happy to go into more detail separately about some of the things we've done to make this work well.
Chris Gmyr
Staff Engineer @ Curology & TrianglePHP Co-organizer
If you're using Laravel 5.5 you can utilize Eloquent API Resources laravel.com/docs/5.5/eloquent-resources which is loosely based on Fractal fractal.thephpleague.com which you could also use instead if you needed something more robust.
Versioning is a tough topic, but this article should help you out blog.apisyouwonthate.com/api-versioning-has-no-ri…