C ++ library call from PHP web application: system () vs SWIG PHP extension?

I have a PHP web application that needs to call a function in a C ++ library. This library is provided by the vendor (libfoo.a on the Linux machine).

  • My first instinct is to create a C ++ executable that references libfoo.a and pass command line parameters to the function. Then the PHP web application can make a call to system () for my C ++ executable. That would be easy to implement. My concern is whether it will add a lot of overhead to create a new system process for each call. How much is overhead?

  • An alternative is that I can use SWIG to port a C ++ function to a PHP extension, but I do not have C ++ source code. Does SWIG support communicate with the ".a" library? Will I require every other engineer in my team to change their PHP configuration to build in libfoo.a?

If the overhead of calling system () is small (<30 ms), I would prefer option # 1, as it seems easier to create a C ++ executable once, rather than embed it in a PHP application. What are your recommendations for the two options?

+5
source share
4 answers

, , php , ++ lib. . , lib. , , , , .. .

, :

0

, ++ vs C , , DLL , .

" , Visual Studio ++ 9, ".

+2

IPC (inter process communication). ++ - - ( TCP/IP unix)

. man 3 daemon, man 2 fork Unix

P.S. PHP - ++ , PHP. php - - . /lib , , - ( ), , -

+1

2. PHP/SWIG, perl, java PLSQL (oracle). C/++ ( libraires), .

, . . ( ) , "" , , - .

:

  • , (PHP ), . perl NewSV.
  • , PHP, .so/.dll
0

All Articles