/tech home / projects / personal 'blog / about


ARCHIVE: PHP Framework Rant

Wed. Mar 1st 2006, 11:31pm:

Presenting my rant from a thread - user: chime about yet another PHP-Framework. Kindly ignore the spelling/grammar errors & typos. I generally don't pay as much attention to my spellings in messageboard posts as I do to my normal 'blog entries. My rant follows:

Here's a request to everyone who's making all these PHP frameworks: Please give me this: RoR AutoCompleter.

In RoR, this is all you need to make an autocomplete input text field:

# view - Just a little test:
<%= text_field_with_auto_complete :contact, :name %>

# controller auto_complete_for :contact, :name
I want to do that in PHP. If I want to convert an input field into a combobox (Google Suggest style), don't make me write 4 different functions in PHP, JS, HTML-onclick-calls to make it work. Do that for me, please. I don't want to declare an ajaxObj for every field or write 2 functions for every input field. That is what a good framework should do for me. We all know how to create an XMLHttpRequest object. Stop calling it ajaxObj with no real benefit.

I use PHP every single day for pretty much all the systems that I make. I'm not an entry level programmer and I cannot afford hiring 10 techs to work under me. If you've ever programmed anything more than a todo-list or online recipe book, say, FDA forms or Quality records, you know there's tens and hundreds of field per document. I want to ajaxify many of these fields but trust me I don't want to write 32 response handlers for 32 fields manually. The framework should be smart enough to recognize something, say an [autocomplete_handler: function stateList()] for a US-States <input> field, and instantly whip out whatever cross-browser-compatible JS/HTML is required to handle inputting states and showing a list of them as the person types. I just want a combobox that's not impossible to maintain.

What if I want to create an invoice form with customer id/name as combobox, and 10-50 items as combobox? Nothing exists right now to make it possible. For every order form, invoice form, sales receipt, or packing slip, I have to manually whip up code to handle one-to-many records. Stuff that is cakewalk in Access is literally impossible in PHP. Say you have a NewEgg order. That order has multiple products on it. You have an order table, and an order_detail table. Now you want to edit the details for that order. I want to display the details for any order in rows, with each field of each row, being editable, ajaxified with combobox/dropdown, and linked to the correct price etc. So when I type in 'AMD' in the 'Item' field of row 4 of the order, I get a combo of all AMD items, and when I pick 'AMD Athlon XP E4342', the correct price is substituted in the field 'Price' for row 4. And some updateSubForm() handler should be called so that I can update the order-total and tax figures.

Yes, it sounds confusing and dull, but that is what people use in enterprises. And right now, because no good Ajax-PHP framework exists, I have to code manually for every single form. Why not make a framework that lets me specify subforms, with fields that have comboboxes from MySQL tables. You know why MS Access (despite have SOOOOO many problems) is so popular? Because you can do what I just asked within minutes - and you don't have to be an Access Pro to do that. I don't want to use Access. I just want those features in PHP so that I can program business logic instead of tracking Javascript errors caused by the difference in implementation of Keyboard Event Keycodes in IE vs FF.

Too many PHP frameworks exist. And I've tried pretty much each and every one of them. If I had the time to write my own framework I would, but I'm more productive making business systems by using PHP than extending PHP frameworks. I will pay to get a good framework. Zend isn't even close.

Here's an example of something done in PHP that is VERY smart - TinyButStrong. It is a one-file templating engine for PHP4/5 and pretty much takes templating to a new level.

# old way: raw php or normal templates
<? [foreach customer_array as customer] { ?>
<? } ?>

# new way: tinybutstrong template <tr> <td>[;block=tr]</td> <td>[customer_array.address]</td> </tr>
TBS takes an array and loops it like foreach would and handles the beginning and ending blocks over which it should cycle. By just adding 'block=tr', TBS understands that customer_array should be iterated over the TR tag. That is clever and saves me from nesting, typing, and writing confusing code. It also cuts down on the need to declare unnecessary variables. It may sound a bit difficult at first and there is a slightly steep learning curve, but once you start using it, you'll never want to write your own foreach loops to output anything ever again. And it has some awesome conditional display features too. In short, this is a templating engine that actually works while making my job as a PHP coder easier and more efficient. Only problem that it is slow to load the first time - almost 0.3seconds - bad for ajax - but if you have a good PHP cache, you're fine.

I had high hopes for PHP-cake but it's coming out very slow. There's some neat things that I like but then again, they don't even have a decent demo. This is what's been linked everywhere for over a year. Where's my two line autocomplete-combobox?!

Thanks for listening.


Update: Visit the original thread to read responses to my post and my rebuttals.