A couple of years ago, PHP sat at the top of the powerful-but-easy-to-use scripting languages heap. And then – suddenly, Ruby on Rails hit the programming world like a ton of bricks. Did you really want a ditch it all for Ruby on Rails and start over? Of course not! What was needed was a new framework that incorporates many of these new advantages without dumping your previous PHP work in the garbage, Thus, the Zend Framework was born. This article shares the concepts behind the Zend Framework, including the Model-View-Controller pattern and the PHP coding standards.
I farted around with PHP a few years ago writing some internal mysql-driven web-based applications we use at work, though I’m not a programmer by trade.
I need to re-visit them and update them, and wasn’t looking forward to reworking the mess of spaghetti code I had created in the past (remember, not a programmer by trade), I literally wrote the apps as I was teaching myself PHP so some of the older code is pretty awful, I can barely understand it myself now. The idea of an actual framework holds some appeal to me. I’d been looking at maybe hooking up with RoR for re-writing/refreshing the applications.
Though I’d prefer to leverage my existing knowledge of PHP, such as it is.
Anyone have any experience with RoR vs PHP/Zend? Not looking for anything too technical, just looking for opinions on either.
FWIW, I’m very lazy by nature, and structured thinking or attention to detail are qualities that are completely absent from my character. Which, frankly, is probably why I’m not a programmer by trade. I just need something that’s quick and easy to work with, I do learn fast.
I don’t have any experience with Zend, but I do with both straight-up PHP as well as Ruby on Rails.
PHP is quick & dirty, and Zend looks like it’ll go a long way toward giving people a pattern that will produce much cleaner code.
Rails is nice, but takes some getting used to once you move beyond the basics. Most tutorials just have you do basic CRUD stuff, the coding for which Rails mostly automates for you.
However, once you start getting into more complex table relationships, there is a much steeper learning curve with ActiveRecord, which is probably the most difficult part of Rails to understand. There are many gotchas that can give you headaches if you fail to catch the smallest detail in the documentation.
I had severe trouble getting some file I/O to work correctly with my ActiveRecord objects, until I discovered a Rails module called “FileColumn”. It seems that Rails, while giving you a very fast and high-level, macro-like coding language, can sometimes feel like a straightjacket if you can’t figure out the exact, koscher “Rails-way” of doing something that isn’t explicitly covered already by the framework. PHP is a LOT more flexible in this regard.
Another temporary shortcoming with Rails is that the IDE space is limited. About the only real option for you is RADRails, an Eclipse plugin. However, it is still very limited: because Ruby is so dynamic, there isn’t very useful code-completion utilities (I suspect that these will be very hard to make for Ruby), and things like breakpointing are rough because the Breakpointer application that comes with Rails feels like more of a hack than a true breakpointing solution — one reason being because you can’t step through code once you hit your breakpoint. It’s also somewhat buggy.
Ruby itself is also a difficult language. It is a very powerful language with clean syntax (think: maintainable Perl in a hyper-OOP environment), but with that power comes some complexity. In PHP (and Java), it’s relatively straightforward to find the source of all your inherited methods and instance variables, but in Ruby, almost anything goes — it’s very very dynamic.
So unless you want to do some pretty simple things with Rails (like generate a quick CRUD app and then focus on writing a pretty, AJAX-y frontend for it), I would suggest you go with PHP just because it’s more predictable for people who are _NOT_ Ninja Codemasters, and there’s much better IDE support, as well as more help forums and other information online.
Edited 2006-06-29 18:39
“PHP is quick & dirty, and Zend looks like it’ll go a long way toward giving people a pattern that will produce much cleaner code. “
Correction: PHP CAN be quick & dirty, but with PHP5 it won’t be, unless you let it.
I love PHP for 2 main reasons: you can do pretty much anything (within reason) with ease, and it really adapts to you – from “spaghetti code” to the most structured OOP.
Thats why PHP is so widely used – even non-coders can take a look at it, hack an application, and evolve with it.
The Zend framework is very good news for RAD, easy to learn, and IMHO helps a lot in keeping clean PHP code (as seen in the coding guidelines).
What else do we need?
Edited 2006-06-30 10:16
To increase your code and program quality quickly start using more classes of pear (pear.php.net). And always check what browser are sending, also know as input validation.
It you look around, there are several code generating MVC frameworks producing CRUD php code (create,read,update,delete), of variable quality.
In the pear you have some too.
With regards
Edited 2006-07-01 01:36
Thanks for the input, that’s some good info.
Quick and dirty was one of the main things that attracted me to PHP, along with the wide array of resources on the web. Others may feel differently, but I’m far less interested in elegance than getting something to work as fast as possible.
However, I need to temper that with some sanity and the ability to re-read my own code afterwards. Think I’ll take a look at Zend. Either way, I’m likely sticking with PHP.
Cheers.
Ever since beeing burned by this bug
http://bugs.php.net/bug.php?id=34783
I’m convinced that Zend and PHP has no future.
They’re to unproffessional. Seriosuly, breaking an important feature with a .1 release and then refusing to fix or revert it becuse it’s “impossible” is just n00bish.
A framework that could use some user(testers?)
http://www.phppeanuts.org/site/