by DCoder · 15y ago · 0 comments
A colleague pointed me to Yii Framework [1] a couple years ago, and I stopped looking for alternatives. Don't see any reason to invent my own frameworks, since Yii has practically every feature I could want already implemented and, more importantly, well tested. In those rare cases when I need to customize or extend something, it's fairly simple to do so, since the code is well documented and organized (though the authors seem to be suffering from a severe allergy to whitespace...).
Controllers with access control rules and filters? Check.
Autoloading? Check.
Caching with support for multiple mechanisms (file cache, db cache, eAccelerator, MemCache, XCache, Zend Data Cache)? Check.
DB layer based on PDO? Check.
ActiveRecord? Check.
Mass attribute assignment to Active Record, complete with validation and allowed/forbidden attribute configuration)? Check.
Named scopes? Check.
Multiple database engine support (MySQL, MSSQL, Oracle, SQLite, PostgreSQL)? Check.
Testing environment? Check.
CLI mode? Check.
I18N support? Check.
Plain PHP views with simple HTML escaping and HTML construction? Check.
Event raising and handling? Check.
[1] http://www.yiiframework.com/
Edit: However, no framework can take away the programmer's stupidity. My former colleague used another framework that has decent support for parametrized queries and still concatenated his SQL from raw user input and printed data into javascript variables by simply wrapping it in '' with no escaping... So glad all of his code has been retired.
Not sure if I'll ever go back to it as I am not really a fan of the syntax and it took me quite long to find out how to do certain things in the given online docs. Might be just me though and really, the first thing I'd say about Yii is that it has got a lot of 'power' under the hood, more than any other available stable PHP frameworks I have seen. Symfony is probably the only other one in that league.
Reinventing the wheel is not the opposite of using a framework. Remember the "favor composition over inheritance" principle? It applies here. Compose libraries rather than inheriting from a framework.
It just happens that PHP has a plethora of frameworks and a dearth of libraries.