Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call an API located on the same server?

I am trying to built a web framework (school project), the framework has to be API-oriented, and I will built the web app on an API-centric architecture, using PHP :

  1. The web backend will be a PHP rest API client
  2. The api backend will be a PHP rest API server and the libraries
  3. They will both be located on the same server, in separated folders

How do I make request to my API located on the same server ? I am afraid that making HTTP request with curl on the same server would be too heavy, what is the other alternative ?

Thanks

like image 965
explogx Avatar asked Oct 18 '22 20:10

explogx


1 Answers

Best way to to call internal api is using local ip address. so if your url is http://example.com/getdata.php then you can use http://127.0.0.1/getdata.php

Hope this will help your

like image 161
Vikas kumar Avatar answered Nov 01 '22 09:11

Vikas kumar