is it possible to have multiple classes inside php extension?
Question by sunset
I would like to wrapp a .cc code that contains multiple public classes. Is it possible to do that ? how? Do I need to use multiple .cc files one for each class that i want to wrapp?
THX
Answer by Chris
You want to call a C++ class from php? This is incredibly difficult. Usually you have to write a php module (a lot of work). Alternatively you could take a look at Thrift which would let you call your C++ code as a network service (sounds hard, but trust me it’s easier than writing a php module).
Answer by Starx
I wonder what you are attempting to do… if motives were mentioned may be we can help better. Anyways….
To execute a compiled application you can use execute()
;
$output = exec('/path/to/your/app');
Besides that, you can always write your own php extension….
Check out these tutorials
- http://devzone.zend.com/article/1021
- http://devzone.zend.com/article/4486-Wrapping-C-Classes-in-a-PHP-Extension
- http://www.devnetwork.net/viewtopic.php?f=14&t=89796
- http://www.devarticles.com/c/a/Cplusplus/Developing-Custom-PHP-Extensions-Part-1/
AFAIK, Many developers use PHP to execute C functions, because it boosts performance quite remarkably.