PHP框架开销 [英] PHP Framework Overhead

查看:79
本文介绍了PHP框架开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多PHP框架;一些是相当体面的,其他的似乎blo肿和不必要的。在观看 Rasmus Lerdorf在Digg 上关于PHP性能的演示文稿后,我更关心性能我选择用于构建我的应用程序的框架。



我知道的两个最流行的框架是CodeIgniter和CakePHP。从我的理解,CakePHP是一个可怕的资源猪。 CodeIgniter怎么样?我听说Zend框架也不是那么苗条。



还有其他(更高性能)框架,我应该感兴趣吗?是不是更好只是不使用一个框架?我应该对选择一个PHP框架做什么考虑?

解决方案

使用框架或不使用框架意味着你


  • 发展速度/稳定性


  • 如果您决定不使用框架,您仍需要 / strong>框架会做的事情。你只是用原始PHP编写自己的代码,或者开发自己的框架,可以保持轻量级,因为它只需要做你想做的,而不是世界想要做的。你会得到更好的性能,但是你会花更多的时间来开发和调试框架自动处理的代码。



    strong>开发时间。你不必写出长的复杂的SQL查询,或调试别人的长复杂的SQL查询。你只需要创建一个表并实例化一个模型。你不需要决定在哪里逃避你的SQL参数,因为框架定义了发生的地方。你不需要进入巨大的政治斗争,在那里的业务逻辑与表示逻辑,因为框架定义了这一点。一个框架消除了在您的团队中拥有一个系统开发人员的需要,或者消除您不必考虑/浪费系统开发的时间。



    这里有另一种方式来思考它,你可以更快地获得可测量的,可见的结果。 PHP框架比PHP慢,但是PHP本身比C慢。为什么不直接在C中写你的应用程序?



    这里没有正确的答案,工程/开发问题,这是你的当前情况需要的问题。现在行业的默认选择是使用一个框架,因为如果你不是你的竞争对手会发布一个应用程序,比PHP更慢的PHP处理,但三个月前击中市场。



    最后,从这次谈话要考虑的最后一件事。 Rasmus说,大多数情况下,你的应用程序的感知性能是在前端。 Javascript代码和浏览器如何缓存它返回到您的服务器的请求。 PHP是一个可怕的可怕语言,很少是瓶颈。当它是瓶颈时,你通常可以做一些调整(选择代码缓存,集中重构),这将消除性能瓶颈。


    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?

    解决方案

    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.

    这篇关于PHP框架开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆