Skip to content
Advertisement

Is object-oriented PHP slow?

I used to use procedural-style PHP. Later, I used to create some classes. Later, I learned Zend Framework and started to program in OOP style. Now my programs are based on my own framework (with elements of cms, but without any design in framework), which is built on the top of the Zend Framework.

Now it consists of lots classes. But the more I program, more I’m afraid. I’m afraid that my program will be slow because of them I’m afraid to add every another one class which can help me to develop but can slow the application.

All I know is that including lots of files slows application (using eAccelerator + gathering all the code in one file can speed up application 20 times!), but I have no idea if creating new classes and objects slows PHP by itself.

Does anyone have any information about it?

Advertisement

Answer

Here’s good article discussing the issue. I also have seen some anecdotal bench-marks that will put OOP PHP overhead at 10-15%
Personally I think OOP is better choice since at the end it may perform better just because it probably was better designed and thought through. Procedural code tends to be messy and hard to maintain. So at the end – it has to be how critical is performance difference for your app vs. ability to maintain, extend and simply comprehend

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement