Create a Method in the same controller and reference it in the form controller like $this->apiController()
public function apiController(){
everything here
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone,
A question more around best approaches here. Within my application with a form (obviously), that is integrated with Google Maps (places for autocomplete) this is a vue js implementation which pings Google APIs to grab the correct data and then subsequently send this data with other form data to the controller to save etc.
However I am wishing to add another API integration which I am happy (and would prefer) to be done behind the scenes as don't want to confuse the user on the front end, but it's a highly valuable data set from an application point of view.
So in simple terms, I am wanting to call a 3rd party API after a successful (validated form submission as I will pass some data from the form to the API). My question is, where is the best place to call/store this 3rd call API integration. It is relatively simple, its a simple endpoint that accepts 1 parameter and returns a simple json object.
Should this integration be bundled in the controller (seems a little bit restrictive and will complicate the controller code), it shoudln't (isn't a model) as it doesn't have any relations - the return data will simply populate some additional DB fields.
How would anyone go about abstracting this service. Any pointers would be well received and greatly appreciated :)
Note this is a pure PHP API integration - no Laravel wrappers etc. For anyone interested - the API is What3Words :)
Cheers
Adam
Create a Method in the same controller and reference it in the form controller like $this->apiController()
public function apiController(){
everything here
}
Please or to participate in this conversation.