My big problem is I need to create some objects, and I found that just to include() their class itself needs time. I tried to use serialize(), unserialize() to speed up object creations, but it only helped some milliseconds, the classes themselves still needs to be required. But this require itself causes delay. Is there a way to cache “classes” ?
Share
There are ways to speed this up like bytecode caching, but it’s often not an option on shared hosting, creates a new dependency and should not be necessary at all for a small project – smartening up the code will probably fix the problem.
Look exactly at what is being included, and whether all of it is needed all the time.
Here is some advice on how to split code into more manageable chunks: How can I improve the performance of 'include()s' in PHP?
Look into PHP autoloading: http://php.net/manual/en/language.oop5.autoload.ph