I have a PHP web application that needs to call a function in a C++ library. This library is provided by a vendor (libfoo.a on a linux machine).
My first instinct is to create a C++ executable that links against libfoo.a, and passes command-line parameters to the function. The PHP web application can then do a system() call to my c++ executable. This would be easy to implement. My concern is whether it would add a lot of overhead to create a new system process for each call. How much would this overhead be?
An alternative is that I could use SWIG to wrap the C++ function in a PHP extension, but I don't have the C++ source code. Does SWIG support linking with a ".a" library? Would it require every other engineer on my team to change their PHP configuration to build in libfoo.a?
If the overhead of the system() call is small (< 30 ms), I would prefer option #1, as it seems much simpler to create the C++ executable once, and not build it into the PHP application. What are your recommendations on the two options?