Skip to content

martin-mueller/coffee-backbone-php-rest-api-skeleton

Repository files navigation

Simple coffeescript backbone.js example app with php-REST api

description

server side (file: server.php)

$allowed_models = array('notes');

no database setup, no data structure setup

doing requests

  • urls for models and collection are the same

Notes example (coffeescript with backbone.js)

class app.Note extends Backbone.Model
urlRoot: 'server.php/notes'
class app.Notes extends Backbone.Collection
url: 'server.php/notes'
  • request format is always application/json

Routes

route/ method GET POST PUT PATCH DELETE
/:model/:id get one create one update one update one delete one
sends back id
/:model/ get all n.a. not implemented n.a. n.a
  • replace :model with your model name (plural)
  • replace :id with model id, ( must be integer !)
  • do not send an id on POST, server.php will create it for you and send it in the response body
  • response header code is alway 200 "OK" for now, will add more codes later

logging

requests are logged into log.txt , so take a look what's going on!

client side

  • example coffeescript/ backbone notes app ( index.html + js-Directory + css -dir )

    Copyright (c) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Coffeescript backbone.js app skeleton example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published