September 13, 2011

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

AFAIK, Many developers use PHP to execute C functions, because it boosts performance quite remarkably.

...

Please fill the form - I will response as fast as I can!