How can the PHP send a file to Java api?
This can be done in several ways: HTTP post, a data stream etc.
Will there be a file server needed ? Or do I need a file server at all?
It depends.
If I need a file server what is the benefit I will get ?
The benefits of a file server is sharing storage resources. It's the same as having a network printer instead of everyone having a cheap desktop printer. With one file server, the PHP program could upload the source file to the file server and them send only the name of the file in a message to the Java API. The result or the process could be stored in the file server and you can download it with another API call. This actually makes the process to be asynchronous. And asynchronous processes are easier to debug and schedule for bulk processing.
Another benefit of it is that in can be managed by a team that takes care of backups, retention times, redundancy, disaster recovery, etc.
EDIT. Why asynchronous processes are easier to debug?
- The two layers don't have to be up and running in order to test one of them. For example for testing the PHP code that uploads the file to the file server, the Java API layer needs not to be up. To test the Java API you don't even have to mock the PHP call. You just put a file in the server and test the Java method that reads the file and compiles it.
- Basically it's easier to debug and test a bulk process that takes a bulk of files and processes it.
- I'll give you an example: for a phone call (a synchronous communication) to go through, there must be a person in the receiving end to pick up the call. On the other hand when you send an email (an asynchronous communication), the recipient needs not be connected to the internet, but as soon as he/she gets online he will receive a notificationo an email message in his/her inbox. You can test the sending part and the receiving part separatelly with no mocking.
- Also, less error handling code must be written, meaning less code to test and debug.