Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Framework Overhead [closed]

There are tons of PHP frameworks out there; some are pretty decent, others seem bloated and unnecessary. After watching Rasmus Lerdorf's presentation on PHP performance at Digg, I'm somewhat more concerned about the performance of the frameworks that I choose for building my applications with.

Two of the most popular frameworks that I'm aware of are CodeIgniter and CakePHP. From what I understand, CakePHP is a terrible resource hog. What about CodeIgniter? I hear that Zend Framework isn't all that slim, either.

Are there other (more performant) frameworks that I should be interested in? Would it be better to simply not use a framework at all? What considerations should I make towards choosing a PHP framework?

like image 445
mattbasta Avatar asked Aug 02 '10 18:08

mattbasta


People also ask

What is a PHP framework?

What Is a PHP Framework? A PHP framework is a platform to create PHP web applications. PHP frameworks provide code libraries for commonly used functions, cutting down on the amount of original code you need to write.

Is WordPress a PHP framework?

A PHP framework is outlined for developers striving with a low-level programming language, the User experience is normally pretty basic. On the other hand, WordPress is a framework that is easy to access even for a non technical person to develop a website.

Is PHP a language or framework?

PHP, or hypertext preprocessor, is an open-source server-side scripting language.

What is raw PHP?

RawPHP is powerful and robust PHP framework that helps people from different PHP backgrounds work on the same project seamlessly. You can write Laravel, CakePHP, Slim, Symphone and Procedural PHP code inside it and it all works perfectly. Its the PHP Framework for everyone.


5 Answers

Using a framework or not using a framework means you're making a choice between

  1. Default Application Performance under load

  2. Speed/Stability of Development

If you decide not to use a framework, you still need to do the things a framework would do. You're just coding them yourself in raw PHP, or developing your own framework that can remain lightweight since it only has to do what you want it to do, and not what the world wants it to do. You will get better performance, but you'll spend more time developing and debugging that code that a framework handles for you automatically.

What a framework buys you is speed in development time. You don't have to write out long complicated SQL queries, or debug someone else's long complicated SQL queries. You just need to create a table and instantiate a model. You don't need to decide where you're going to escape your SQL paramaters, because the framework defines where that happens. You don't need to get into huge political fights over where the business logic vs. presentation logic goes, because the framework defines this. A framework remove the need from having a system developer on your team, or removes you from having to think about/waste time on system development. You can get to coding your application faster and get measurable, visible results sooner.

Here's another way to think of it. PHP Frameworks are slower than PHP, but PHP itself is slower than C. Why not write your application directly in C?

There's no right answer here, it's one of those software engineering/development questions that's a matter of what your current situation demands. The default choice of the industry these days is to use a framework, because if you don't your competitors will release an application that has slower PHP processing than yours, but hits the market three months earlier.

Finally, one last thing to consider from that talk. Rasmus said that Most of the time the perceived performance of your application is in the frontend. Both the Javascript code and how the browser is caching the requests it makes back to your server. PHP is an awful, horrible language that's rarely the bottleneck. When it is the bottle neck, you can usually make a few adjustments (opt code cache, focused refactoring) that will remove the performance bottleneck.

like image 189
Alan Storm Avatar answered Oct 21 '22 08:10

Alan Storm


you might want to look into the lightweight frameworks category. there's fat-free, doophp, limonade, etc. they're lightweight, but not less-powerful than you might think. don't rely on published benchmarks. instead, benchmark against your own objectives.

like image 24
bcosca Avatar answered Oct 21 '22 08:10

bcosca


IMHO, the advantages of using a framework far outweigh the disadvantages of any overhead costs that may come with it. Of course there are always exceptions to the rule, these being:
- The project is small enough to not warrant a framework
- The framework itself is horribly designed

But for the majority of cases, you shouldn't worry about it. I've been using Symfony (versions 1.2 & 1.4) on a number of projects, and haven't once thought "this is too resource heavy". I will gladly sacrifice some resources in exchange for all the tools a framework provides that makes my life easier, and the job take less time ;)

like image 41
Steven Mercatante Avatar answered Oct 21 '22 09:10

Steven Mercatante


I have built some big applications with the Yii PHP framework. It's pretty speedy because it "lazy" auto-loads classes. I have no performance complaints.

If you run a PHP opcode cache/accelerator like APC or eAccelerator, and do all of the usual best practices for page loading speed on LAMP setups, then using a PHP framework will be WELL WORTH IT for the development time saved. Performance will not really be an issue unless you are serving an astronomical number of requests!

like image 37
thaddeusmt Avatar answered Oct 21 '22 08:10

thaddeusmt


I've only used CakePhp in anger over a period of several years. Yes, it is big and may seem bloated but, to be honest, I think that if I had used any other framework it would be as big by the time I've added everything that I have and use with Cake.

Speed-wise, we're talking small fractions of seconds difference between the contenders. Optimizing your site using tools like Yslow and gzip and, of course, sensible design, will realize greater improvements than the choice of framework.

http://www.grasset.es is a site I built about 4 years ago with Cake. It's big and complex, but I don't think it's slow.

like image 21
Leo Avatar answered Oct 21 '22 10:10

Leo