I've got 1 server with more than ten different standalone applications, all written in PHP. These applications communicate with each other through an API. There is one application on top to let them communicate with clients from outside the server, globally it looks like this:
The app who has to handle the hit responds in JSON to App 1, App 1 generates an appropriate answer to the hit, such as a webpage, image or just plain JSON, based on the information in the JSON.
If an application needs to communicate with another application, he will send a HTTP-request with cURL. Basically he becomes a client on his own server. I know this method consumes more resources than using a direct function, like Include or Require. But when I use these functions, I lose a lot of the standalone-principles.
The reason I like to stick with my standalone-principles is that I like to work with external junior programmers. I don’t want them to be obliged to use things like OOP, Classes etc. I want to say to them: “This is the input, I expect the output to be this, create a PHP-application to achieve it”.
My questions are:
- Does the HTTP-method use many more resources compared to direct functions like Include or Require?
- Are there better ways, besides Include or Require, to build a internal API with PHP?!