43 Comments
- chime, on 10/12/2007, -1/+4Here's a request to everyone who's making all these PHP frameworks:
Please give me this: http://demo.script.aculo.us/ajax/autocompleter
In RoR, this is all you need to make an autocomplete input text field:
####### start ########
# view
Just a little test:
[%= text_field_with_auto_complete :contact, :name %]
# controller
auto_complete_for :contact, :name
####### end ########
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 damn 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 a [autocomplete_handler: function stateList()] for a US-Sttates 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 damn 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 damn 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 substitute in the field 'Price' for row 4.
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. 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.
Too many PHP frameworks exist. And I've tried pretty much each nad 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 - http://www.tinybutstrong.com/
It is a one-file templating engine for PHP4/5 and pretty much takes templating to a new level. It is hard to explain here without full HTML tags but Instead of writing [loop php-array] [tr] [td] [data] [/td] [/tr] [/loop array], you can do [tr] [td loop-array-over-td] [data] [/td] [/tr] and it works. 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 - http://wiki.cakephp.org/tutorials:complex_model_validation_routines - but again, they don't even have a decent demo. This - http://cake.sendbits.com/posts/ - is what's been linked everywhere for over a year. Where's my two line goddamned autocomplete-combobox!
Thanks for listening. - inkswamp, on 10/12/2007, -0/+2Why is it I keep hearing so much about AJAX in the context of frameworks? Is it so confusing that we need to insulate ourselves from the process with a framework or am I misunderstanding the whole point? I mean, at the heart of AJAX, it's just an http request going on behind the scenes, right? Beyond that, what's so difficult to get about this? Everyone keeps carrying on like it's the reinvention of the wheel, but if you already understand Javascript/DHTML, what's the big freakin' deal and why does it always have to be packaged up in frameworks to make it "easier"?
Sorry for the rant, but this puzzles me. - gabrielsond, on 10/12/2007, -0/+2If you don't like it, don't read it and let everyone else decide for themselves...
I found this to be very interesting... digg++ - noph44, on 10/12/2007, -0/+1Hmmm, I think your problem may be client side. I have no problem with slow loading of comments. Besides, web 2.0 has little to do with ajax, its more about the user-driven administration.
- jiminoc, on 10/12/2007, -0/+1you guys don't seem to think the prototype library is bloated???
http://www.snook.ca/archives/prototype1280.png
just check out that diagram. my-bic is more of a design pattern than a "framework". - inactive, on 10/12/2007, -0/+1Buzzword alert.
- digg - dilvie, on 10/12/2007, -0/+1Perhaps because the prototype library does a hell of a lot more than you typically need it to do.
- hadem, on 10/12/2007, -0/+1Why no just use Ruby on Rails then? :)
- chime, on 10/12/2007, -0/+1hamoe: Of course I have tons of custom written libraries that help me do what I want. I've classes and general functions for a lot of things. Here's an example of something I wrote - arrayColumnSort() function on http://us3.php.net/array_multisort (by php a-t-the-r-a-t-e chir.ag - 05-Jan-2006 03:10). If you have an array with fields/keys "name", "city", "state" and you want to sort DESC on state and ASC on name, this function will do it. The normal array_multisort function requires a lot of manipulation to sort by contents of different keys.
What I'm saying is, yes, I have pretty much looked into everything I can possibly find that'll make me write less PHP code and give more results. I digg, Slashdot, PlanetPHP, and Google about PHP more than I probably should. And yeah I've tried Smarty. It's great for a lot of things but I just don't want to deal with {section/loop/strip/nesting} when better solutions (like the block=tag attribute in TinyButStrong) exist. I have better ways to cache my PHP/Template files so that's not a big issue for me. And TBS caches too. Just check out the examples: http://www.tinybutstrong.com/examples.php and view the Output, the HTML Template, the HTML source, and the PHP source. It'll take some time to hit but once it hits, you're gonna go OMG this is brilliant. Well, at least I did.
"A good programmer writes reusable code, and it sounds like that is basically what you are looking for."
I have reusable code. I don't want libraries to help me do stuff. I want PHP as a language or add-on frameworks to provide me with features that make development faster/easier/simpler. Like I mentioned subforms. A framework can give me features and functions to make that possible. I can have an objSubForm() class/object and once I define my table relationships, it should be able to show me a form with subforms that I can use to add/view/edit/delete. There's lots of framework that do basic CRUD - I need more!
"check out Behaviour. It is a small library dependent on prototype that lets you easily define rules for all js events in one place, outside of your html tags."
I've used it and like it a lot for some things. But my whole rant was that I don't want to code JS. I can, but I don't want to. I want to write my business logic in PHP, and without me having to repeat anything twice, just have it work. E.g. validations. I want to ensure that the 'City' field is never blank. Two places to validate - JS on the client side, and PHP on the server side. Right now, I have to write code to do it both places. A good framework should do that for me - I'll define the validation rules in PHP, and the framework will split the JS code upon request to make sure the validation happens on the client end too before user hits 'Submit'. Cake-PHP does this - http://wiki.cakephp.org/tutorials:complex_model_validation_routines - but I want it even simpler, mainly because I have over 40 fields in some tables (no I cannot normalize it any more). I do not want to write 40 validation functions for 40 fields. Sometimes I just want to bunch them up - all text fields must be non-empty, all date fields must be in future etc. And sometimes I want to bunch most fields up except one or two - all money/currency fields must be positive except the Ajdustment field which can be + or -, but it can't be string-text.
These are requests from a heavy user - not a once-a-month coder. I will pay/donate good money for a framework that stuff I want, because then I can go ahead with my ERP system instead of having to write every little grid, combobox, and treeview class myself by importing unconnected code from Yahoo Widgets and dotvoid, dojo and god knows where else. You know how .NET is a framework in which the Treeview can talk to the Grid and Combobox? Give me that in PHP - I'll write the code, I'll write a million lines of code if necessary, but I don't want to write one widget.
I want to write business logic - what happens when the inventory is short and the customer places a huge order for an item which has a lead time of 3 months but only if the vendor has been paid 25% in advance? My boss doesn't care about Dojo or Ajax or TBS or Smarty. He cares about his TPS reports and in all honesty, that's what makes money for us. I want to give him and all my coworkers the interfaces that help them do their jobs the best, but I don't want to go nuts while trying to debug WHY the hell does a keyboard event for page-up key that fires normally in FF not fire in IE? I guess I am asking for things that probably Zend would only be capable of providing but I highly doubt that I am the only one who needs a better Ajax/UI framework.
We have good DB frameworks already for PHP and frankly, I don't want to use Ruby-style DB-access Base:: etc. Unless you're doing basic CRUD, scaffolding is pretty much useless. In my system, any time a record is changed, depending on who changed it, 12 other things need to happen, none of which are provided by scaffolding. I don't mind writing code to handle that. But I do mind writing code to set $("state").value = response.Value for 32 different pages that all use US-style Address fields. If only I could specify somewhere in a framework/ui-class that treat this field 'State' like it belongs to class 'Address->State' or something and give it all the ajaxy goodness defined in class 'Ajax->State'.
SilverRocket:
I tried Rails and did my best to understand it like a native Ruby programmer but it just doesn't seem as big of a benefit for me to switch as the 10min demo pretends. Too many rules and naming conventions to follow to make it work like it is supposed to. Installation on cPanel was a nightmare anyway. If you already have tables that are not defined using Rails' logic, it's not easy to make it work. My table name is ordersum (for Order Summary) and orderdet (for Order Detail). Rails wants me to rename them to orders with main field being 'id' instead of what I always use 'orderid' - too many things for me to change to actually benefit marginally. It's a pretty language with amazing features - just not worth recoding 5-yrs and tens of thousands of lines of working code merely for ajaxy-goodness. - Bitruder, on 10/12/2007, -1/+2I've been using script.aculo.us and the Prototype JS library for all of my AJAX needs in my PHP applications and they work great in my opinion and the javascript needed is very minimal. Personally, all of the work I do is in manipulating the data passed back and forth so I like that THAT part of everything can be neat and tidy in the Prototype library and I only have MY php which I know and understand and can work with easily.
- discobean, on 10/12/2007, -0/+1from my pov xoad is so far the best framework I've found
- thall, on 10/12/2007, -0/+1After reading through the various docs of ajax projects posted in previous comments, I must say prototype looks like a well-established toolkit and a much needed stepping stone to build a user-friendly framework like chime mentioned.
I haven't seen yet, even in the project that started this whole thread, something that pushes the input parameters from a FORM on the client to the PHP script on the server. Lots of helper functions to snatch the response and translate it to a JavaScript object, but even prototype.js and My-Bic fail to implement the reverse to automatically serialize a JavaScript object for submission.
I think prototype.js needs to support JSON a bit better (or at least document it better). If I were to write an intelligent PHP-AJAX framework (hey maybe it should be called PAJAX) I'd prefer to collect the parameters I need to pass to PHP into a JavaScript object, then pass the object to some method in prototype's AJAX class. From there it would automatically call the .toSource() method on the object and run that through encodeURI() or encodeURIComponent() to form the query line. From there, the PHP functions in My-Bic would automatically decode and translate that JSON to a PHP object and pass it to whatever user handler.
That PHP code would likewise put the response data into a PHP object and pass it to the PHP class for JSON encoding and transmission to the client. Prototype would pick up the response, decode and "eval" it back to a JavaScript object. No XML required (but admittedly it does have it's place), and no need to have user JavaScript code compute a goofy hash-look-a-like-array.
Also, I like the idea prototype offers to extend form elements, but it to me it doesn't look like a good job of abstracting those elements....but it gets points for trying; the tools are there for it, they just need to be pieced together differently for the forms. - agimat, on 10/12/2007, -0/+0"If web 2.0 is so great, why do the comments on digg load so slow?"
Its because of all the whining. - phishyJon, on 10/12/2007, -0/+0looks useful to me, i might try it out tonight. good dig.
and skaagent: get used to it and quite whining. - dbr_onix, on 10/12/2007, -0/+0Not quite sure where the "Easy" part of it comes into things, it looks horrible syntax-wise...
- Ben - jiminoc, on 10/12/2007, -0/+0thats the purpose of this "framework". It doesn't try and do anything but make it easy to use the xmlhttp object. Its 4 files, hardly a massive framework. Read the description on the site
- pbjorge12, on 10/12/2007, -0/+0"Why is it I keep hearing so much about AJAX in the context of frameworks? Is it so confusing that we need to insulate ourselves from the process with a framework or am I misunderstanding the whole point? I mean, at the heart of AJAX, it's just an http request going on behind the scenes, right? Beyond that, what's so difficult to get about this? Everyone keeps carrying on like it's the reinvention of the wheel, but if you already understand Javascript/DHTML, what's the big freakin' deal and why does it always have to be packaged up in frameworks to make it "easier"?"
I like AJAX frameworks because some of them have very interesting features...I know DOJO allows you to easily get the "back button" working in AJAX apps...
But I agree that their are too many... - mixd, on 10/12/2007, -0/+0http://saja.sourceforge.net/
- Barnstormer, on 10/12/2007, -1/+1If web 2.0 is so great, why do the comments on digg load so slow?
- inactive, on 10/12/2007, -0/+0Using AJAX to load the entire contents of the site on each page? You guys are taking AJAX way beyond it's suggested means.
- discobean, on 10/12/2007, -0/+0pbjorge - "But I agree that their are too many..."
Not really, the whole ajax framework thing is relatively new, so let them develop as many as they want, in the end the strongest will survive! - pkkid, on 10/12/2007, -0/+0Doesn't work in IE7
- jupo, on 10/12/2007, -0/+0This doesn't seem too useful at this point. The JavaScript required to do the same from scratch is no more than a few lines extra. It appears that the XHR object and all the main ways of accessing it have been abstracted out into a class that does little more than its underlying object. Given how the amount of extra functionality the example provides there doesn't seem much point compared to more mature frameworks available. Also the PHP class seems to do little more than format JSON requests using some gargantuan library, or return plain text along with some errorQ logging functionality.
Having said all that the code is very cleanly written, it just has a long way to go. I also like the diagrams on the website. - abdulmueid, on 10/12/2007, -0/+0Dont forget the moo.fx js library which uses prototype. It's just 3KB and works out of box.
http://moofx.mad4milk.net - SilverRocket, on 10/12/2007, -0/+0Chime, I face the same challenges as you mention: making very intelligent web-apps with lots of forms and ajax calls for auto-filling many fields based on the content of any field, etc.. it takes a long, long time. the php, the javascript, the DOM manipulation, the css, the actual form-processings and of course the debugging and error-checking/handling. i can't afford underlings either. the result is that some complicated modules take a long long time. perhaps its time to investigate Rails. but i'm not sure i have the time to learn yet another language.
- SilverRocket, on 10/12/2007, -0/+0Jiminoc: for people who just need the 'basics' of prototype (read: most people who AREN'T creating sophisticated javascript work), there is a prototype-lite library out there that is 1/10th the size and provides simple Ajax stuff, the $() function, and a few functions. One can pick it up on the moo.fx site if I recall correctly, http://moofx.mad4milk.net
- thall, on 10/12/2007, -0/+0chime, you're hitting good points, i've been thinking of taking a swing at such a framework and so far i think what's needed is:
- a form management system (the entry point to the system, called by onLoad) to collect data and structure things listed next
- a rich collection of widgets, where widget code is made of both PHP and JavaScript
- a flexible, yet transparent, templating system to define the form structure, instantiate static widgets, etc
- a stylesheet system to dynamically control the form, the widgets, and the template. one effect of this stylesheet would be to actually pull in true CSS stylesheets as well as dynamically assign CSS styles to various elements.
I see lots of toolkits, and widgets are starting to form all over the web, and we have static templating like TBS, but I haven't seen anything that lends itself to simple form management and form/widget/template stylesheets.
XSLT even comes close, since by nature it will iterate over whatever input data you throw at it, and the output is structured according to template rules, but things get real hairy when you have it autogenerate JavaScript code.
Off the top of my head, an example might be a generic page to dump the result of a mysql query, with the header row auto-generated, and displaying each data row uses alternating background colors. The template would include a reference to a table widget which, when fed with data, generates the table element, the header row, and the data rows by instantiating row widgets through the form manager, which would would get run through the widget stylesheet rules. You'd have a style sheet rule saying that the CSS backgroundColor for each new row comes from cycling through an array of color definitions. The row widget would take its data and instantiate cell widgets, again with any stylesheet rules applied. - maseone, on 10/12/2007, -0/+0um, la bled = labeled (lol, thanks spellcheck)
- maseone, on 10/12/2007, -0/+0Back to the post...
though i like the simplicity, not sure why it was la bled "easy". I'd have to say some of the other frameworks are quite a bit "easier" than this one.
Back to the comments...
Wow, this is one of the best threads I've read in digg for a while. Thanks for your time peeps! - CaughtThinking, on 10/12/2007, -0/+0Prototype goes hand in hand with RoR *cough*
Take a hint from masters like Zillow.com and use X.
http://cross-browser.com/ - clofresh, on 10/12/2007, -1/+0Doesn't use the prototype framework, so it's USELESS. After discovering prototype, why would you ever want to write Javascript without it?
http://www.sergiopereira.com/articles/prototype.js.html - hamoe, on 10/12/2007, -1/+0@chime
If you're consistently writing code to handle similar problems on a variety of websites, why don't you write your code in a generalized fashion in the first place. I'm not suggesting you take the time to write a full-fledged framework, but there is no reason why you should be writing routines to handle every field in every form on every site. A good programmer writes reusable code, and it sounds like that is basically what you are looking for.
Regarding the templating, tinybutstrong is a novel and functional template system, but I'd highly recommend Smarty (smarty.php.net). If you have not had an opportunity to check it out, it is a very powerful template system and unlike tinybutstrong compiles its templates into PHP files.
Also, like a previous poster mentioned, the prototype javascript library makes this sort of web development much less painful, and if you are using it, definitely check out Behaviour. It is a small library dependent on prototype that lets you easily define rules for all js events in one place, outside of your html tags. It also makes available the extremely useful getElementsBySelector() function, which lets you get element handles by specifying CSS selectors (eg getElementsBySelect("div.reply") returns an array of div elements with the "reply" class).. others might mention that prototype makes available the $$() function which does the same thing, but that is not in the current stable prototype library... - alej744, on 10/12/2007, -2/+1AJAX is waaaayyyy better than Mr. Clean, you all suck!
- clearrecrd, on 10/12/2007, -5/+3@sketchstudios-
LOL- good stuff - inactive, on 10/12/2007, -3/+1use mr clean to get rid of the ajax mess
- sketchstudios, on 10/12/2007, -17/+12screw ajax, use this.
http://www.mrclean.com/ - tweakr, on 10/12/2007, -6/+1lol, noob :P
- KnuxSonic, on 10/12/2007, -6/+0NO MOAR AJAX PLZ!
- TheRepublic, on 10/12/2007, -6/+0LMFAO... good clueless comment sketchstudios
- inactive, on 10/12/2007, -6/+0too much ajax on digg
- inactive, on 10/12/2007, -7/+0"Every other day there's either an article on ubuntu, linux commands, or ajax on digg. STOP SUBMITTING THIS *****!"
Dont forget Ipod, web 2.0 and the likes - SkaAgent11, on 10/12/2007, -9/+0Every other day there's either an article on ubuntu, linux commands, or ajax on digg. STOP SUBMITTING THIS *****!


What is Digg?
Digg is coming to a city (and computer) near you! Check out all the details on our