Page 1 of 1

PHP Request/Response Model

Posted: Tue Nov 07, 2006 1:18 pm
by MrPotatoes
i cannot find a decent tutorial and i am pretty sure i know what it is. i have one currently but imo nothing is every good enough so i decided to look around and i can't find diddly

a Request/Response Model would be something that grabs whatever the user just did and responds to it. so (client) Request -> (system) Response. now, i have an HTTP class that handles POST/GET. i planned to change it some more once i finish my forms generator/validator class. i planned to have that as part of my R/R Model as well

i'm ramblining. i guess i'm just looking for is to learn more about Request/Response Models and how they can relate to a framework (controller -> handler). also, i learned about AJAX awhile back and that it's an asynchronous system that does things behind the scenes so i don't have to refresh. as i understand it at least. i like this and would like to impliment it if i can.

___________
i'm thinking AJAX will handle this but is there a way to do this without AJAX. that is my first question. and secondly are there any libraries that handle it that can do it with PHP, have decent tutorials and licences are commercial free. that second one is a must. i don't mind re-writing it down the line but for right now to show off i want that licence.


thank you for your help

Posted: Tue Nov 07, 2006 1:48 pm
by MrPotatoes
well this explained it pretty well (still on the first page). so i guess i would like to know how to develop a Synchronous "request/response" communication model and then build an AJAX asynchronous layer on top of that. problem is that i'm having a hard time designing one in my head (i do that before i put it to paper).

any tutorials on such things?

http://www.developer.com/design/article.php/3526681

Posted: Tue Nov 07, 2006 1:52 pm
by Luke
I'm not 100% sure what you're asking... but if you want to build an application with an ajax layer, just use zend's Zend_Json or something similar to output javascript-parseable data.

Posted: Tue Nov 07, 2006 2:34 pm
by Christopher
As far as the "Request/Response Model" I think your naming is telling ... because both the Request and Response are Models in the true sense. Both are data containers with additional logic for them to perform their tasks. The Request contains a data representation of the external inputs into your program; the Response contains and assembles the program's output. The application lies between those two and has additional inputs that are typically datasources or services.

Both abstract the external interface for you. The Request has system data as its input and an interface that you define for its output. The Response reverses that. So the real question is what interface do you want/need to have to the input and output of your program. HTTP has pretty specific needs so these interfaces are pretty common framework to framework.

Ajax does not change the cycle or this objects -- it just adds additional actions to your program.

Posted: Tue Nov 07, 2006 2:37 pm
by Maugrim_The_Reaper
I think AJAX and Javascript is pretty much what you're aiming for. If you have an application with a set of buttons, input elements, etc., you can setup events to call a handler Javascript function. This handler would spark an XMLHttpRequest transaction with the server, retrieve a response (whether plain text, html, xml or JSON) and update the current page via a second handler function in Javascript.

Any of that make sense? I'm currently writing a tutorial (internal project documentation) which demonstrates using AJAX, Javascript and the Zend Framework 0.20 to build a very simple app. I'll PM you a link (not quite ready to have an unfinished text hit prime time ;)).

Posted: Tue Nov 07, 2006 2:52 pm
by MrPotatoes
thanx for the help guys.

i'd love a PM link to that tutorial you're writing.

i'm thinking that i'm going to put more effort into the current RR that i plan to add the ajax layer on top of it to make it seem less like a browser based app.

:D

Posted: Fri Nov 10, 2006 11:18 am
by MrPotatoes
event driven. THAT'S what i'm looking for in my Reqest/Response model. that's what i plan to impliment. so i'm looking into WACT because they have a system that i kinda idolize minus his over reaching OOP-ing. i've already got a pretty sweet system but i think event based is what it has been missing and what i've been trying to create

http://www.phpwact.org/wact/controller_ ... ent_driven

also, i've found a 'class' that handles and creates events. i plan to review that and see how i can create my own. if there are any tutorials that you know of don't hesitate to post the links here :D

oh. secondly i'll be using (if i can think it through well enough andthen impliment) the observer pattern so this way i don't have to use call_user_func. i was never a fan of that anyways