1
I’m looking in the documentation of Laravel, in several places , but I haven’t had success yet I’m looking for somewhere that has a tutorial how to consume an api with Laravel!
1
I’m looking in the documentation of Laravel, in several places , but I haven’t had success yet I’m looking for somewhere that has a tutorial how to consume an api with Laravel!
0
Regardless of what your Framework is, before consuming something you need to understand what it is to actually consume an API. This will make it easier.
Behold:
An API is nothing more than a set of public (or otherwise) routes (links) that will provide data in a specific format (ultimately JSON).
Note that, in other words, you need to make your Laravel access links and interpret their feedback.
As such, you need ideas for making requests through your system. For this we have a few options:
Pure CURL call with PHP http://php.net/manual/en/curl.examples-basic.php
Call CURL via Shell_exec (for linux); https://incarnate.github.io/curl-to-php/
Some package that abstracts the process: https://medium.com/laravel-5-the-right-way/using-guzzlehttp-with-laravel-1dbea1f633da
Regardless of the choice, you will be anyway making a request to another server, in case what provides the API service you need.
In terms of architecture, I believe that the ideal for this is not to use the controller itself, but rather a layer of Services for this process.
An example of this are systems that have integrations with Free Market, I have an application like this and, in this case, I set up a service that is responsible for all negotiations involving the API. This facilitates the process because once done, I no longer need to think about how the API actually works, just use my mounted service that abstracts the process.
Alternative 1:
Alternative 2:
Alternative 3:
Yes, I understand how it works already, until already created using Passport , authentication and validation with tokens ,already consumed using in Ionic 3 , now I want to consume it in the Standard
See if I can shed some light
Browser other questions tagged php laravel api framework
You are not signed in. Login or sign up in order to post.
Which API you want to consume?
– David Dias
my own , already consumed it using Ionic , and very simple has 3 fields only
id
,email
,senha
with Passport ,but not yet tested in the Standard , already used in Postman and Ionic 3– Luska Zimmermann