Hello good people ,
am build a web application using Laravel for a group, this group also want an android application , so my andriod friend told me that he need an api so that my mobiel app can access the registration and login data base .
SO i needed to learn API , and use a laravel lib like Passport & dingo etc
i Need from some one to draw the road to me , what to learn how to use it in laravel ? best lib ?
Again am using laravel so i need some thing that i can integrated with it .
thk in advance guys .
I was able to get started pretty quickly with the following boilerplate: github.com/francescomalatesta/laravel-api-boilerp…
To add on top of Hugo Rodrigues's answer, I would also include Dingo API which includes a lot of nice features for APIs such as versioning, rate limiting, formatting responses, and generating documentation. My main issue with the documentation generator is that it creates a single Markdown file, so you may want to use a different tool for that if you expect your API to be very big.
It's important to know the role of the API in your architecture and understand that documentation is very important to other developers or for your future self so in this matter I recommend apidocjs.com . It helps you generating a nice documentation based on comments using a defined structure and it leverages versioning that could help you in the future.
Another thing that's important to keep in mind is that an API should be stateless, so you should use laravel's 'api' middleware, some developers struggle with this issue, I know I have.
For functional testing use getpostman.com or insomnia.rest However you should always write unit tests for code, I know that this isn't always possible write them as much as possible.
Regarding packages, it always depends on the purpose of the API but i recommend, for:
Authentication: github.com/tymondesigns/jwt-auth/wiki/Installatio… You don't really need to use Passport for authentication, a simple JWT should do the trick.
Transformers: fractal.thephpleague.com Usually as the API grows so does the complexity of the presentation and transformation layer and fractal really provides a easier way to transform your data before returning the requests.
CORS: github.com/barryvdh/laravel-cors. Depending on the purpose of the API you could need to expose some headers and increase your API security. You can learn more at developer.mozilla.org/en-US/docs/Web/HTTP/Access_…