recommend a good web-application framework for PHP?

by Derek Sivers

Related link: http://www.oreillynet.com/pub/wlg/5885



I'm spending WAY too much time just on the web UI interface to my projects!

I wish I had a good re-usable framework for all these web-apps. Any suggestions?

Rails looks interesting, but I can't just switch 50,000 lines of PHP over to Ruby for it. I've got all my shared classes in PHP already. Maybe I'd use it for a brand new project some day.

As I mentioned before, Tony Marston has an interesting approach that looks very tempting to throw myself into.

Perl's Mason looks REALLY nice, and some dude I respect loves it. But again : I can't switch all my code over to Perl for it. Is there anything like Mason for PHP?

PEAR's HTML_QuickForm looks like it would help with forms, but not a complete solution. Maybe an ingredient to something bigger.

I'm just not into Smarty, for the same reasons described by Brian Lozier and others.

In fact - I'm really into typical templates at ALL -- because the way I use PHP is not the typical fashion : I don't put PHP inside HTML. I have PHP do *everything*, only a small part of which is spitting out some HTML to the browser. Since all my sites are mutli-lingual, with ALL words as a $lang hash/array/dictionary stored in a config file, and since all page-layout is CSS, there's almost nothing on an HTML page that is *not* dynamic. Just the occasional div, span, ul, li, p, input, etc. My HTML is practically an XML file : just my dynamic values, with some basic identifiying markup tags wrapped around those values. (div id="cart", ul id="menu") Nothing worth making a static template for.

Again: I really like Mason's component-approach. Hey I wonder if there's a way to have PHP do the business-logic, and have Perl/Mason do the display-logic?

I know that millions of hours of brain-power have been spent by smarter folks than me, developing database-driven websites, and they must have created some framework somewhere that matches my needs - but I haven't found it yet. (Though it's funny that the two I like the best so far are in Ruby and Perl -- c'mon PHP! What's up with that?)

suggestions?


12 Comments

trickie@gmail.com
2004-12-07 17:30:17
Try this one
WACT


For more information you might want to talk to HarryF via his site PHPPatterns. He is one of the authors.

marccanter
2004-12-08 10:09:49
Drupal
What's wrong with Drupal?


You don't need to use everything, but they certainly have their website framework act together.

HarryF
2004-12-09 03:00:34
Template engine or framework?
Focusing on the specific problem: "I'm spending WAY too much time just on the web UI interface to my projects!"


What is the exact problem here? If the problem is that drawing the UI takes too much effort (and it sounds like it is) then the solution, as you seem to have explored, is something in the line of a template engine, rather than a framework.


Jumping straight to a framework is likely to lead to re-writing alot more code and won't (necessarily) solve the problem of UI generation.


Also a template engine itself may not make your life easier (and many will make it harder) unless it provides some mechanism for you to build re-usable user interface components (e.g. a reusable result set pager).


Believe Smarty has some simple mechanism to allow you to write reusable UI components, which they call plugins - see here. Not using Smarty myself so can't say more.


An alternative to Smarty, which you may prefer, is phpsavant: http://phpsavant.com/yawiki/. Savant is a template engine which (strange as it may sound) uses PHP itself as the template language. The idea is you exert some self discipline and restrict yourself to only basic PHP syntax / functions in the template. Savant helps you cleanly seperate the template logic from everything else. It also has a "plugin" mechanism to allow for re-use - see http://phpsavant.com/yawiki/index.php?page=PluginRef.


Both Smarty and Savant (as well as Perl's Mason and many other template engines) primarily use some form of imperative syntax (if/else, while etc.).


The alternative view is some form of declarative markup. The leaders of the field here are Microsoft with ASP.NET but there's also Java's Taglibs and more recently Java Server Faces. The easiest way to think about declarative template markup is simply as an extension to HTML's own tag set to include addition tags with names like "calendar" and "dataset". The "extended tags" only exist on the server side (within the template), the end result being normal HTML delivered to the client. In some ways this approach is the best suited to building reusable UI components. The downside of this approach is it adds alot of complexity (plus wierd employment of Javascript in the case of ASP.NET and JSF).


In general, highly recommend reading this study of template engines http://wact.sourceforge.net/index.php/TemplateView. It doesn't advocate a particular approach but helps alot in understanding the general problem, which can help alot in narrowing requirements. The bottom line, IMO, is no one has got the perfect solution for everyone (no matter what they tell you).


Finally the hard sell. WACT, which I've been involved with, provides a number of general components for building web applications, on in particular being a template engine. It uses the declarative approach mentioned above and is, IMO, the most evolved of this kind in PHP. But it's only just reached version 0.2 (alpha) so if you start using it, you may end up contributing - be warned!


There's also an MVC implementation in there so you have the option of using WACT as a framework as well. The more of WACTs components you use, the more benefits you gain (e.g. template engine + MVC controllers makes for very powerful form handling) but the more of your existing code you're likely to need to re-write.


One final thing on frameworks - there's a pretty exhaustive list of PHP MVC frameworks here. By way of recommendation, Jeff (WACT's lead developer) says he'd use Mojavi if he wasn't using WACT.

i8ramin
2004-12-13 08:21:02
Cocoon for PHP
I've been reading up on Cocoon and it looks like a very promising application framework to me. It is completely based on XML, so I'm not sure if it applies to you. There is also a group of people who are porting Cocoon to PHP. They called it Popoon.. just google bitflux and/or popoon and you'll find the page.
RobbyRussell
2004-12-19 07:56:58
PRADO
Derek,


Have you taken a look at PRADO yet? It won the Zend PHP5 coding cotest and looks to be fairly promising and reminded me of WACT, but seems to have a larger community and is a bit more mature (documentation and example-wise).


http://www.xisc.com/


Cheers

sporkmonger
2005-01-27 13:45:46
Funny that...
I'm been thinking the same thing for about 3 months or so now; decided to just write what I needed myself, but I'm targetting ASP.Net and not PHP, so it won't do you a whole lot of good I guess. :-/
andig
2005-05-10 01:09:02
Learn from the commercials?
Why not look at some of the commercial frameworks out there? I've done lots of work with Siebel CRM and really love the structure:


- database layer (tables, columns)
- business component (BC) layer (logical object, usually sitting atop a table like contact, account), including refrences to other BCs or tables
- business object (BO) layer (logical grouping of BCs)
- screen/view (UI container based on BO, contains applets)
- applets (based on BCs and containted in views, end user representation of underlying BC)


It's absolutely amazing how fast any functionality for DB-driven applications can be contructed this way. The whole thing is contained in a run-time environment similiar to an application server.


Is there anything like that for PHP/Java? Wouldn't such a solution be a big push for fast development of PHP/Java based large scale applications? From what I understand of w.g. horde, they're only dealing with the plain basics, but this would go much further into direction of a *full* framework.


Comments?


Thanks,
Andi

thinkcomp
2005-06-22 19:59:41
Lampshade


Take a look at Lampshade, a PHP framework we've developed over the past few years. It's extremely simple, and it works.



http://www.thinkcomputer.com/software/lampshade

Elegantscripts.com
2005-07-13 02:22:34
Very nice
Very nicePHP Articles (http://www.phpscriptschool.com)
DW007
2005-07-15 12:15:44
Cake (PHP on Rails)
http://sputnik.pl/cake/
plewicki
2005-08-05 07:45:25
PAS
PAS (Application Server for PHP)


It offers all the feature of Modern Framework. Created in 1999 its very mature and used in enterprise level projects and applications.


http://www.sqlfusion.org/


Their is also a commercial development tools for it:
http://www.webfusionstudio.com/

Supernerd
2005-12-21 14:14:47
Zoop Framework for PHP
Perhaps you should look into zoopframework for php. It supports smarty for templates, but also supports you not using smarty. It is quite stable and mature, being used in production for the last 5 years. It has a few features unique to it, one being guiControls and another being forms. Other than that it also has all that you would expect a mature framework to have including MVC and AJAX support.


http://zoopframework.com