Well I’ve been designing my own String and Array classes for my application framework, it works pretty well so far but there is a problem. With arrays it’s not an issue as my class extends PHP’s SplFixedArray and performance is actually better than PHP built-in array. With string however, the string object is about 3-5x slower than PHP native string.
I’ve been researching into how to improve performance further, and this idea of writing PHP extension comes into my eyes. It seems that writing a PHP class in C/C++ as an extension is considerably faster than writing in PHP, it can come in handy with objects that you will likely to mass produce(string for instance). However, I still have a few questions about writing PHP extensions.
- How can I port a C/C++ class into PHP from application code? As I am writing a software that will be used by clients, they may install/run my script on shared hosts. Is this gonna be a problem as it probably needs to recompile PHP source code?
- The hacker’s guide to write classes has nothing in it, no idea why. Anyone actually has a tutorial for writing PHP extensions for classes? Or is there a book/online-tutorial that describes how to write PHP extensions in details?
http://www.php.net/manual/en/internals2.classes.php
Id appreciate if any of you advanced/expert coders answer my questions, many thanks for just reading through it.