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?
Id appreciate if any of you advanced/expert coders answer my questions, many thanks for just reading through it.
If you're using a shared hosting it is highly unlikely you will be able to add custom extensions for the reason you mentioned.
The first thing would be to learn c. You probably won't get very far without at least intermediate/advanced understanding of c and computer science principles. All the things we take for granted in PHP like memory management aren't done so automatically in c. Not mention understanding make files and compiling which is one big pain when compared to the ease of PHP and other interpreted languages.
This topic is now closed. New replies are no longer allowed.