Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3951774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:46:15+00:00 2026-05-20T01:46:15+00:00

I have just finished coding up a relatively involved web service in PHP. The

  • 0

I have just “finished” coding up a relatively involved web service in PHP. The code base is now a bit of a mess due to last minute requests, changes, add-ons, the usual.

I tried to code it as lightly as possible and in a manner that would maximise performance.

Therefore, I didn’t use any frameworks like Zend or any ORMs like Doctrine.

I was wondering if there are any frameworks or design patterns that exist for the sole purpose of building APIs/web services in PHP?

I’m thinking of a refactor and I want to make sure now I know exactly what’s involved I can build this thing properly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:46:16+00:00Added an answer on May 20, 2026 at 1:46 am

    I apologize in advance for the self-reference here to my own framework – there’s no way for me to help you otherwise since I don’t use anything else. I’m not advertising, since it’s not public.

    As I said in my comment, I think a good web front-end framework shouldn’t mean it is a poor web service framework.

    Because I was unsatisfied with the restrictive way any of the popular PHP frameworks (CodeIgniter, CakePHP, Kohana) processed requests, as well as their size, I wrote a framework that is designed for really only two purposes, process a request and determine an action to take, and then separate the code for that action from the view (response).

    The design pattern I use is this:

    1. All URLs are rewritten (mod_rewrite) and passed to your execution entry point.
    2. Your entry point sets up paths that it will recognize and process. I.E. for a web service:
      • /users – User list
      • /user/* – User identified by the value where * is.
      • /user/*/delete – Delete the user
      • /posts – List posts
      • /post/* – View post *
    3. Along with the path you specify a function, I.E. UserActions::saveUser to be executed if the HTTP method is POST. The reason it’s only executed on POST is to enable output and input to have the same URL.
    4. The path also specifies a view. This is the response body that will be sent to the browser. It can be rendered as straight PHP, or you could plug in a template engine. In the case of web services, all paths would probably use a single view that renders your data in the output format (JSON, XML, whatever). The view can be just a PHP method and is not required to specify a template file.
    5. In the case of a web front-end, the view can have a parent view which wraps it (creating the page from the inside-out).
    6. The last point is security. You can define a security type to be applied to any path. A security type just specifies what function (like SecurityManager::authorize) to check for authorization and if false is returned, it redirects to a path of your choosing.

    The reasons I believe this design pattern works well for Web Services:

    • Enables you to use a single-entry point, but can be used with multiple entry points (for optimization, if needed).
    • No assuming that you want your URLs to match your Object Model, like most of the major frameworks do (a notable exception being Zend, as mentioned in the comments).
    • Easily adapted to REST (instead of just checking for POST, check for other methods too).
    • The removal of any HTML feels completely natural, since in this pattern the response is completely separated from processing.
    • This can all be done in a few classes.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just finished reading 'Java for Dummies' and have begun to create a simple
Have just started to get into CakePHP since a couple of weeks back. I
I have a NSWindow that I'm putting into fullscreen mode. I would like to
I have a result screen that shows bonus points and such. I want each
I have a method like the following: - (void)add:(id)sender { MyAddViewController *controller = nil;
I installed orchard through the MS web platform installer. It listed web matrix as
I'm writing a Windows service to process files created by another process over which
I have developed a silverlight 3 application using Sockets connecting to a socket server
I am hoping the saveLayer methods will allow me to do draw onto different
I'm trying to build an usercontrol wich is able to take elements from XAML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.