关于Yaf的一些说明
作者: Laruence( ) 本文地址: http://www.laruence.com/2012/08/31/2742.html 转载请注明出处 Yaf 是我在俩年前写的一个PHP扩展的MVC框架. 开发Yaf的目的是为了解决使用框架带来的性能下降的经典矛盾. 最初要感谢百度的同仁们的信任, 以及当时各位老大的支持
- 作者: Laruence(
)
- 本文地址: http://www.laruence.com/2012/08/31/2742.html
- 转载请注明出处
Yaf 是我在俩年前写的一个PHP扩展的MVC框架. 开发Yaf的目的是为了解决使用框架带来的性能下降的经典矛盾.
最初要感谢百度的同仁们的信任, 以及当时各位老大的支持, 容许也敢于让我”试错”, 才让Yaf顺利的度过了”没人敢用”的阶段, 大量的百度的新的产品基于Yaf开发, 让Yaf的稳定性得到了充分的验证, 也普遍的提高了PHP应用的执行效率.
而现在, Yaf的高性能又一次在微博的应用中得到了证明, 通过迁移框架到Yaf, 和一些其他优化手段, 我们成功的让新版微博的TPS提高了76%之多, 响应时间下降了近一半.
然而, 我也看到, 还有不少同学对Yaf有疑虑, 甚至有质疑, 有人认为”使用C写框架? 那不是回退到写CGI的时代了?”, 于是我想我有必要写一篇文章, 详细介绍下我对Yaf的一些理解.
首先, Yaf是一个框架, 那么大家对框架有什么感觉? 比如大家在平时使用Yii, Zend Framework的时候, 会去修改它么? 当你的一个业务基于某个框架开发完成以后, 你觉得你以后还会去修改框架代码么?
这就是Yaf之所以可以做成框架的一个前提条件, 那就是框架是不易变的, 一般是不需要维护的, 比如在百度使用的Yaf, 相当于Yaf 2.1.0, 虽然从2.1.0 到现在的2.1.18, 新增了一些特性, 修复了一些bug, 但是只要你的应用基于此框架开发完成了, 稳定运行了, 那你并不是一定要把框架升级到最新版.
第二, 大家在使用其他框架的时候, 如果要调试, 会需要去读框架代码, 并且通过在框架代码中打信息来调试么? 我想说, 这样的情况, 很少很少, 是的, 当一个开发者对某个框架特别熟悉的时候, 他清楚的知道这些框架的流程, 所以可能通过这样的方式来调试, 然而这不是必须的.
Yaf因为是扩展, 所以特别注意开发/调试的便利性, 它提供了插件机制, 提供了丰富的debug信息, 并且专门为命令行下的调试做了特别优化, 尽可能的在出现错误的时候, 给予更多的错误原因. 所以, 你几乎完全不需要了解框架的具体实现, 就能方便的调试.
还有一些同学对Yaf的实现表示担忧, 害怕引入一个扩展, 会造成一些其他问题.
Yaf的实现, 都是基于PHP的内核API, 你可以理解为Yaf的执行层面, 和你的PHP代码执行层面没有不同, 并且充分的注意了避免对PHP带来侵入性, 他遵守所有的安全限制, 所以在PHP内载入Yaf, 并不会带来什么问题(当然, 除非你的应用中, 有和Yaf提供的类同名的类).
还有一些同学, 担心, 万一Yaf出了bug怎么办? 毕竟扩展的框架, 要维护比较困难.
首先, Yaf有bug么? 肯定有, 就好比PHP, 它也存在很多Bug, 但是只要你触及不到, 那么你就不会触及到, 不存在开发的时候没问题, 跑的时候有问题.
另外, 对于Yaf的问题, 我基本上能做到快速响应, 这点现在的大量的Yaf用户应该能证明吧? 如果真正的是Yaf的bug, 我一定会立即修复. 提供Patch. 并且, 除我之外, 也有更多的人对Yaf的实现开始了解, 我相信以后Yaf会有更多的维护者.
另外, 还有不少同学问, 为什么Yaf没有ORM, 这里有俩方面的考虑:
首先, Yaf并不是万能的, 它只是解决了应用中, 最基本的一个问题, 就是框架带来的额外的性能开销, 然而这本部分的开销和你的应用实际的开销相比, 往往是很小的.
但是, Yaf却代表着一种精神, 就是追求简单, 追求高效, 追求:”简单可依赖”, 所以Yaf专注于实现最核心的功能, 提供最稳定的实现.
相比ORM, 如果要实现的很方便, 那必然会很复杂, 在当时的情况下, 实现ORM有可能会引入不稳定性
第二, 也是最重要的一点是PHP已经提供了对DB的一个轻度封装的PDO, 我认为直接使用PDO, 会更加简单, 更加高效, 我不希望提供一个复杂的ORM包装, 鼓励大家去抛弃简单的PDO而使用ORM. 所以, 最初的时候, Yaf并不包含ORM.
诚然, ORM可以提高开发效率, 尤其对于一些简单应用, 所以我想在后续的Yaf的版本中, 会考虑加入ORM, 但是那也绝对会是一个简单的ORM, 类似于Yaf的内建视图引擎: Yaf_View_Simple, 简单可依赖.
当然, 因为Yaf是扩展, 而大部分的虚拟主机提供商是不容许我们自己安装扩展的, 这也就限制了Yaf的应用面, 在这点上, 我想我要特别感谢SAE/BAE的同学们, 在不久的将来, SAE/BAE都会支持Yaf, 让更多的个人开发者, 也能使用Yaf.
Yaf相比其他的框架, 目前还是一个很年轻的东西, 虽然有一大堆热心的同学(大门, 黑馒头, 烧鸡, 等等)在和我一起努力去丰富文档, 提供实例, 但Yaf的相关辅助还却是不如其他框架丰富.
所以, Yaf对于完全没有用过框架的同学来说, 入门门槛会比较高一些, 但如果你已经使用过其他框架, 那么接受Yaf, 将会比你想象的简单的多.
最后, 我并不是说, 大家都需要使用更高性能的框架, 我只是希望Yaf能给大家提供了一条路, 给大家提供多一种选择而已.
“Yaf只是最快的框架, 却不是最完美的框架.”
我会让持续的让他越来越完美. 我也欢迎你, 和我一起, 让他变的更完美.
在Github上的Yaf源代码: https://github.com/laruence/php-yaf
在Pecl的Yaf的发布包: http://pecl.php.net/yaf
Comments
- 2012/08/31, 飞晏 writes: 我在公司的最后一个项目确定使用yaf了,不过还不确定我们的架构师会不会使用PDO。一般我们都习惯使用ORM去做,因为实在是太忙了...
- 2012/08/31, 雪候鸟 writes: @飞晏 那你可以使用第三方的ORM库, 只要它符合自动加载规则就行. :)
- 2012/08/31, 老黎 writes: 简单可依赖.这话深深打动了我呐...
- 2012/08/31, syber writes: 鸟哥,这篇blog我不水了!
- 2012/08/31, pangee writes: 鸟哥,当年“才让Yaf顺利的度过了”没人敢用”的阶段, 大量的百度的新的产品基于Yaf开发”这个阶段,是否出现过YAF问题一大堆的情况?。。。
- 2012/08/31, 雪候鸟 writes: @pangee 呵呵, 没有, :) 我的代码还是值得你信任的
- 2012/08/31, pangee writes: "Yaf却代表着一种精神, 就是追求简单, 追求高效, 追求:”简单可依赖”" 赞 ~
- 2012/08/31, ruckfull writes: 简单,可靠,看着很动心
- 2012/08/31, 奇言妙事-文学奇谈小小说阅读xlinblog.sinaapp.com » 关于Yaf的一些说明 writes: [...] 本文地址: http://www.laruence.com/2012/08/31/2742.html [...]
- 2012/08/31, Demon writes: 爱yaf,爱wife。yaf你值得拥有。
- 2012/09/01, PHP10086博客网 writes: 是不是考虑 研究一下鸟哥的yaf 嘿嘿,鸟哥真给力--简单可以依赖!
- 2012/09/01, demo writes: 必须要用。
- 2012/09/02, 关于Yaf的一些说明树林/咖啡 成都专业php网站制作 | 树林/咖啡 成都专业php网站制作 writes: [...] 风雪之隅 ? PHP应用 Posted in: php / Tagged: 关于Yaf的一些说明 [...]
- 2012/09/04, 疯狂的火星人 writes: 可以先试试,不过windows 下配置安装不是很方便呀,这样在windows 下开发的童鞋,就有点麻烦了!!
- 2012/09/04, erain writes: Hi鸟哥,请问一下什么时候Yaf才会支持PHP 5.4?我们公司马上要开展的一个PHP项目我很想基于Yaf来做,但是我们生产环境上的PHP都已经升级到5.4了……
- 2012/09/04, 雪候鸟 writes: @erain 一直支持5.4, 只不过你不能pecl install, 你下载下来自己编译就行...
- 2012/09/05, dennis writes: 建议鸟哥出本书。
- 2012/09/05, hipop writes: 我们正在用yaf来部分代替zendframework,实践证明yaf无疑是php发展过程中一个伟大的尝试,希望yaf发展壮大!
- 2012/09/09, 小悠 writes: 感觉这样会不会有点问题? 有没有想过将PHP的数据库这部分用C来写
- 2012/09/16, Ray writes: 期待SAE的YAF
- 2012/09/18, 奇言妙事-文学奇谈小小说阅读xlinblog.sinaapp.com » Yaf and Phalcon, which is faster? writes: [...] 关于Yaf的一些说明 [...]
- 2012/10/10, anonymous writes: 有意思,值得关注
- 2012/10/21, wake writes: Laruence 您好,想請教一個關於 Yaf route 的問題。我希望能在 route rules 裡動態指定對應處理的 controller/action,例如透過 Yaf_Route_Regex 規則捕捉到了兩個變數,則就以這兩個變數作為 controller 和 action。 我目前是透過 Plugin 的方式做攔截和轉譯,想請問有沒有比較簡單的方式 (直接透過 route) 可以作到呢?
- 2012/11/12, 刘纪君 writes: 现在我已经把zendframwork下面的应用转接到yaf下面很简单的转化,效率非常的高。
- 2012/11/15, Sam writes: 求教,某些单纯的REST,纯API型的应用。如何让Controller不需要去加载视图。。
- 2012/11/15, 安卓DIY writes: 安卓DIY(www.anzhuodiy.com)是用Yii实现的,研究了一下Yaf,确实很简单,看能不能迁到这上面。
- 2012/12/06, 关于PHP的编译和执行分离 | 5iphp writes: [...] 关于Yaf的一些说明 [...]
- 2013/04/01, peter writes: 下一个项目可以尝试用一下,称研究一下。
- 2013/04/30, 关于Yaf的一些说明 | 午后小憩 writes: [...] 本文地址: http://www.laruence.com/2012/08/31/2742.html [...]
- 2013/05/01, 关于PHP的编译和执行分离 | 午后小憩 writes: [...] 关于Yaf的一些说明 [...]
- 2013/05/12, weijiao writes: Fatal error: Uncaught exception 'Yaf_Exception_LoadFailed_Action' with message 'There is no method indexAction in IndexController' in /data/www/yaf/index.php:4 Stack trace: #0 /data/www/yaf/index.php(4): Yaf_Application->run() #1 {main} thrown in /data/www/yaf/index.php on line 4 这是我在nginx运行yaf之后出现的错误,可以保证的是代码是没有错的。
- 2013/05/12, weijiao writes: 希望开发者能尽快回复,我只是运行hello world的简单代码,但是nginx就是出现这个问题,第一次运行的时候是出现结果了但是不断刷新就出错啦!!求救!!!!!
- 2013/05/12, laruence writes: @weijiao 如果你是使用Yaf新版, 我可以保证你的代码或者配置是有问题的...... anyway, 这里有个Yaf的qq群, 你可以加入进来提问: 5134185
- 2013/05/13, weijiao writes: 那个群我加了,不过我早已经把问题贴出去啦,可是没有人能真正帮我解决的,哎,怎么办!
- 2013/09/30, 上海天气预报 writes: 最近很少用框架
- 2013/12/07, lihi writes: getControllerName(); /** * Use access controller is unecessary for APIs */ if (in_array(strtolower($controller), array( 'api', ))) { return TRUE; } if (Yaf_Session::getInstance()->has("login")) { return TRUE; } /* Use access check failed, need to login */ $response->redirect("http://yourdomain.com/login/"); return FALSE; } ?> $response->redirect("http://yourdomain.com/login/"); 我怎么没找到redirect这个方法呢?
- 2013/12/20, WildCat writes: sae到现在没实现yaf
- 2014/08/22, 上官 writes: 鸟哥 公司决定用了yaf框架 项目中需要实现widget的功能 求思路
- 2014/09/16, 133-inch macbook pro, apple a1097, macbook pro, apple macbook pro, superdrive mac g5, 133-inch laptop,tablets for business, apple ipad, iphone covers deals, iphone 4 accessories, iphone covers coupon codes writes: The supplementary information density and most up-to-date Seagate technologies need to afford it the edge above prior Professional-types. That benefits the aluminum along with instruments glaas enclosure. My homepage ... 133-inch macbook pro, apple a1097, macbook pro, apple macbook pro, superdrive mac g5, 133-inch laptop,tablets for business, apple ipad, iphone covers deals, iphone 4 accessories, iphone covers coupon codes
- 2014/09/21, get into bondage writes: Unfortunately, many managers who really want to do the right thing just don't recognize it when it happens, and they end up handling grievances or, worse, lawsuits. Let's take a look on how you can pick lingerie for your special person. Try a babydoll with a cut-away front in a misty blue color. Also visit my site - get into bondage
- 2014/12/13, plus size trendy clothing writes: Hi to every body, it's my first pay a visit of this webpage; this webpage consists of remarkable and really excellent information for readers.
Copyright © 2010 风雪之隅 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Are you wondering where to find or how to change your MAC address on Windows 11, but you don’t know how to do it yet? Since it is possible to hide the IP address, this article will provide simplified steps to set a custom MAC address from the device properties on Windows 11. Can the MAC address be changed? It is possible to change the default MAC address of a Windows computer, but device manufacturers strongly recommend not doing so as it may cause unexpected problems. On the Network Interface Controller (NIC), the MAC address is hardcoded and cannot be changed, but with some drivers this may be possible. In addition, users can also use third-party programs to change the MAC address

Address Resolution Protocol (ARP) is used to map MAC addresses to IP addresses. All hosts on the network will have their own IP address, but the network interface card (NIC) will have a MAC address rather than an IP address. ARP is a protocol used to associate IP addresses with MAC addresses. All these entries are collected and placed in the ARP cache. The mapped addresses are stored in cache and they usually do no harm. However, if the entries are incorrect or the ARP cache is corrupt, you may experience connectivity issues, loading issues, or errors. Therefore, you need to clear the ARP cache and fix the error. In this article, we will look at different methods on how to clear ARP cache. method

Sometimes it is necessary to assign multiple addresses to a single LAN card. For example, if you need to run multiple websites with unique IP addresses or bind applications to different IP addresses, etc. If you are thinking about how to assign multiple addresses to a single network interface card or LAN card, this article will help you achieve it. Follow the steps below till the end and it will be done. So let’s get started! Assign multiple IP addresses to one LAN card Step 1: Use the Windows+R keys together to open the run prompt and type ncpa.cpl, then press the Enter key to open the Network Connection window. Step 2: Right click on your network adapter Ethernet or WiFi option and click Properties. Step 3: From the Properties Window

Any device connected to the Internet has two types of addresses - a physical address and an Internet address. While Internet addresses locate devices globally, physical addresses help identify specific devices connected to a local network. This physical address is technically called a MAC address, and if you're wondering if your iPhone has one, yes, all phones (including iPhones) have their own unique MAC address. What is a MAC address? The Media Access Control or MAC address is a unique indicator used to identify your device from other devices connected to the same network. If you have a device that can connect to the internet, it will register a MAC address. This address is owned by

Why do I need to assign a secondary IP address in Windows 11? Now, we come to the most important question, why do you need to assign a secondary IP address or even multiple in Windows 11? Assuming you have a device with a default IP address and want to use another device, this may require adding a secondary device. Apart from this, it is also used to host various SSL websites. If you have to send a large amount of email in a short period of time, it may be helpful to obtain multiple IP addresses, as there are limits on how much can be sent from one IP address in a specific time frame. Additionally, some users set it up to avoid being blacklisted by spam filters. In addition, add auxiliary

Apple’s official after-sales phone number: Apple’s 24-hour service center phone number: 400-666-8800. The after-sales service telephone number for Apple mobile phones is: 400-666-8800. -627-2273. Apple’s customer service manual service hotline is 400-627-2273 for after-sales support; 400-666-8800 for the online store; and the only official Apple phone number is 400-666-8800. Apple's customer service hotline is 400-666-8800. You can call this number to inquire about hardware, software and third-party accessories of Apple products. It should be noted that Apple’s manual customer service does not provide services 24 hours a day. Their service hours are from 9 a.m. to 9 p.m. (Sundays are from 9 a.m. to 9 p.m.

When it comes to Word, not everything can or needs to be written in plain text. Writing everything down in long descriptive text can really make your Word document boring and confusing. Of course, the comment feature is an option. But even adding comments can make your document look so clunky and heavy. But how do you hover over text that requires a short description and have a little box appear over it with the text you want displayed? Well, this sentence can be called ScreenTip. Once you've inserted a ScreenTip into your document, whenever you want to see the descriptive text you've added, just hover your mouse over the text or line where the ScreenTip was inserted. In this article, we list 2 different methods that you can use to achieve the same purpose. follow

1. Where can I change my Meituan address? Meituan address modification tutorial! Method (1) 1. Enter Meituan My Page and click Settings. 2. Select personal information. 3. Click the shipping address again. 4. Finally, select the address you want to modify, click the pen icon on the right side of the address, and modify it. Method (2) 1. On the homepage of the Meituan app, click Takeout, then click More Functions after entering. 2. In the More interface, click Manage Address. 3. In the My Shipping Address interface, select Edit. 4. Modify them one by one according to your needs, and finally click to save the address.
