如何调用位于同一服务器上的API?

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

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