menu

天魔窟

勇往直前

Avatar

PHP Fat-Free Framework, looks nice~

PHP 的理念中最突出的应该是简单和快速,专门用于 web 开发。遗憾的是,发展到现在的 6.0 版本已经越来越像 Java 一样臃肿了。

除了语言本身,层出不穷的 PHP 框架也在致力于催肥 PHP,明明可以一行 echo 解决的问题非要先写个类?

当初开发 sinzy 的程序我选择了 CodeIgniter 这个框架,主要还是看上了它的性能优势。CI 并非完全走的开源开发的模式,其母公司的新产品迟迟不能推出,也许是 CI 升级缓慢的原因之一。

今天看到一个新的 PHP 框架:Fat-Free Framework,简称 F3,走的就是 minimal 的路线:PHP5,3 个小包含文件,不要求固定的目录结构,MVC,模块化……作者最后一段感言我觉得很能起共鸣:

IN RETROSPECT

Too often we see code hyped up as "frameworks". But when it comes to applying them to real-world situations, they fall short and sloppy or at the other end of the scale - are huge beasts that behave like control freaks - which make them unusable or hostile to average programmers.

Some are touted as frameworks yet they act simply as front-end controllers which do nothing more than route URLs to classes, functions or include files. They make programming a bit easier, but lacking in many MVC aspects. Some require a fixed directory structure - an open invitation to hackers. Other procedural frameworks use method chaining (which can be quite long), you'd wonder at times what the right sequence should be. Some are just too bloated with so many features than you'll ever need to use in simple blog or wiki applications.

Most frameworks brag about being "lightweight" - which seems to be a relative term. Does a 50MByte framework that consumes a lot of resources qualify as lightweight? Let's call a spade a spade. A cargo truck is lightweight compared to a jumbo jet. Indeed. But if all we need to do to get from here to there on a "regular" basis is a car with some room to spare, why ride the space shuttle? Extra features are more often overkill, like using a jackhammer to drive a half-inch nail.

It seems like in the name of "improving" their software, developers simply forgot or ignored the fact that frameworks are meant to support structures, that is, make applications easier to fabricate and provide order along with industrial strength - not to be imposing structures themselves. This point is argumentative and has been going on since the days of the pyramid builders. Architects and engineers have gone thru endless debates because the first is focused on artistic freedom, the latter on structural integrity.

At the other extreme, the term "lightweight" also means a framework lacking in features that count the most. So it becomes necessary to integrate a lot of third-party modules just to make up for the most important ingredients.

Whichever the case may be, balance and minimalism in framework design - where elegant architectural patterns, engineering excellence and Formula-1 performance are available - is not a philosophy that's commonplace. However, it does manage to find its niche here and there.

This is where the PHP Fat-Free Framework makes its mark. The minimalist framework is so rooted in its Zen world of construction components, that an entire Web application can be developed in so little, yet streamlined, code. That of course means a lot when we're talking programmer productivity and time-to-deploy.

In fact, the Fat-Free Core Pack command set has only 20 static methods and 6 template directives. It weighs in at a compact 40KB of source code (and half of it is inline documentation) - but make no mistake about its puny size, it's got everything a Web designer needs to get any kind of job done. You won't see the fancy and mostly unnecessary stuff found in bloated frameworks. It aims to be usable - not usual. It's very much like a modern compact Javascript toolkit for PHP.

Fat-Free gives you a lot of freedom. It won't change your programming style, only your habits - albeit due to the powerful tools you'll have at your disposal. Despite that, Fat-Free is certainly not a be-all, end-all framework. It's not for everyone - only for those who want raw power behind simplicity.


会抽时间看看。

很感兴趣,准备找时间看看

F3这个东西要怎么用!!求教!!!有意者加QQ971929221谢谢