PHP, JS & Service layers: Blend like never before

By Freeaqingme on maandag 14 maart 2011 20:15 - Comments (9)
Category: Zend Framework, Views: 19.077

The past week I've been only programming (clientside) Javascript, and last night I finally got to tying it all to the serverside app, which is written in PHP. While adding some functionality to my Service Layer, it came to mind how much slower this process was in the past. Tweeted about that realization, and was asked to blog about it, so here I am.

As mentioned, I use service layers (stricly spoken that should probably be singular). All they do is proxy requests to my mappers, and in the mean time log the request and check if the user performing it is actually allowed to do so.

When adding a new feature to the clientside part of my app I used to add a function to my javascript that performs an xmlhttprequest to a custom url, parse the output, and then update one or more elements based on the result. Serverside, I would then add a route to the file where all urls are mapped to their relevant module/controller/view, created a controller or action that would parse the data as was received from the javascript, call the appropriate method in the relevant service class, parse the result from the service layer call, and send it back to the client. Yes, you're right: That's quite a tedious job indeed.

Read more »