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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:09:06+00:00 2026-06-05T20:09:06+00:00

I have been looking into backbone.js and I can’t seem to figure out how

  • 0

I have been looking into backbone.js and I can’t seem to figure out how to get it communicate with php in order to save the models data. It sends a request but how do I capture that request whether it be “Create”, “Update”, “Read”, “Delete” etc.

Thanks

  • 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-06-05T20:09:07+00:00Added an answer on June 5, 2026 at 8:09 pm

    Another option you may consider is to roll with a pre-packaged RESTful framework that has all the necessary functions built in to execute your Backbone server queries. My personal favorite is Josh Lockhart’s SlimPHP Framework.

    Some simple sample code (once you have SlimPHP setup) used to take your Backbone calls look like this.

    $app->get('/user', function() use ($app) {
    
        // See if session is set, get user info as array
        if (isset($_SESSION['userID']) {
             $user = // grab user with userID data from DB
        }
    
        // Respond to the get request with a json object
        $response = $app->response;
        $response['Content-Type'] = 'application/json';
        $response->body(json_encode($user));
    }
    

    Here is a POST example that turns Backbone json into arrays.

    // Middleware that detects type of data and converts it to something usable
    $app->add('Slim_Middleware_ContentTypes');    // JSON to associative array
    
    ...
    
    $app->post('/message', function() use ($app) {
        $dataIn = $app->request()->getBody();
    
        ...
    
        // Save to DB $dataIn['message'], $dataIn['author'], etc.
    }
    

    Here is a PUT example using some parameters.

    $app->put('/user/:id', function($id) use ($app) {
    
        // Find appropriate user from DB that has $id as ID
    
        $dataIn = $app->request()->getBody();
    
        // Save to DB $dataIn['name'], $dataIn['age'], etc.
    }
    

    And here is a DELETE.

    $app->delete('/message/:id', function($id) use ($app) {
    
        // Find appropriate message from DB that has $id as ID
    
        // Delete message with id of $id
    }
    

    While this isn’t an exhaustive example of all the other things to consider, it should give you an idea of the kinds of open solutions already out there for you to use. I personally like Slim because it is so lightweight, simple, yet it has all the features you’d want in a RESTful server. Great for prototyping. Combine it with a DB abstraction layer and some other tools and you can make just about anything you want quicker.

    You can see some other sample code along these lines here:

    1. How to post Backbone model to server
    2. Ways to save Backbone data

    And here is a link to some other PHP based RESTful solutions: Framework List

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into this for a while and can't figure it out.
I have been looking into MVVM recently and I seem to get the overall
I have been looking into this for some hours now and can't figure it
I have been looking into the php fputcsv function, and have heard some comments
I have been looking into using tools for UI testing automatically and seem to
So i have been looking into JNI calls so i can interact with some
I have been looking into some options for creating a slide out bar for
I am an experienced PHP programmer, but I have been looking into Ruby lately,
I have been looking into recursion and TCO. It seems that TCO can make
I have been looking into Code First with Entity Framework CTP4 and you can

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.