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 3676722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:08:02+00:00 2026-05-19T03:08:02+00:00

I have read many about REST api in php articles. but I still get

  • 0

I have read many about REST api in php articles. but I still get quite confusing.

they basically rewrite the url to a index.php, which process the url and depends on the method, then send response

but which is the properly way to process the url? this looks doen’t look correct…

  1. get the uri and split it
  2. I should know what to do with each portion, eg. for GET /usr/1 I should do something like:
    if($myUri[0]==”usr”)
    getUser($myUri[1]);

if the request url is like GET www.domain.com/user/1
it would call getUser($id);
but what happen if you can also retrieve the user by name, or maybe e-mail? so the url can also be www.domain.com/user/john or www.domain.com/user/john@gmail.com
and each url should call different methods like getUsrByName($name) or getUsrByEmail($mail)

  • 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-19T03:08:03+00:00Added an answer on May 19, 2026 at 3:08 am

    The proper way of handling this would be to have URLs like this:

    domain.com/user/id/1               -> user::getById
    domain.com/user/email/foo@bar.com  -> user::getByEmail
    domain.com/user/username/foo       -> user::getByUsername
    

    However, specifying multiple “parameters” is more like a search, I’d go against using resources for that, because a path should be absolute. Which means:

    domain.com/user/name/Kossel/likes/StackOverflow
    

    And:

    domain.com/user/likes/StackOverflow/name/Kossel
    

    Are not the same resource. Instead I’d do:

    domain.com/user/?name=Kossel&likes=StackOverflow
    

    This is what Stack Overflow uses:

    stackoverflow.com/questions/tagged/php
    stackoverflow.com/tags/php/new
    stackoverflow.com/questions/tagged/mysql?sort=featured
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many posts about this now but I do not still understand
I have read many topics about UITableViews not refreshing on iPhone, but couldn't find
I have read many articles about linq to sql performance. The result which i
I am beginning to write a Facebook application. I have read many articles about
I have read many topics about cut/copy to clipboard, but haven't found the answer
I have read so many articles about integration and yet i did not found
Alright...I've given the site a fair search and have read over many posts about
I have read many posts about setting up unit testing in Zend Framework and
I have read many php tutorials for logout scripts, i am wondering what could
I've read many thread posts, articles etc. about binding and the thread affinity of

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.