Developers have been reqesting examples of how to integrate Backbone.js with a number of different backend technology stacks. To help with this, you can find six of these integration examples in this repository, with their stacks listed below. There are more to come soon and I'm always happy to consider other stacks not already covered.
(thanks to Lauri Piispanen)
- Slim PHP RESTful framework
(thanks to Joshua Stauter)
- Rails / Rails Asset Pipeline
- Rails JSON API
(also thanks to Joshua Stauter)
All boilerplates are based on the excellent HTML5 Boilerplate and use a MongoDB backend.
Please ensure you have MongoDB installed and running prior to running any of the boilerplates.
Once you've downloaded MongoDB, you'll need to complete two steps to get things up and running.
MongoDB stores data in the bin/data/db folder but won't actually create this directory for you. Navigate to where you've downloaded and extracted Mongo and run the following from terminal:
sudo mkdir -p /data/db/ sudo chown `id -u` /data/db
Running and connecting to your server
Once this is done, open up two terminal windows.
In the first,
cd to your MongoDB bin directory or type in the complete path to it. You'll need to start mongod.
Next, in the second terminal, start the mongo shell which will connect up to localhost by default.
###Options 1 and 2
The only main difference between Options 1 and 2 is that Option 2 uses Jade (the Node templating engine) whilst Option 1 allows you to use regular HTML for your layouts. Both run on Node.js with Express and Mongoose.
To get either option running:
- Make sure you have Node.js installed. If not, grab it here
- Next, fire up a terminal and run the following lines
git clone https://github.com/addyosmani/backbone-boilerplates.git cd option1 ./install.sh node app.js
Similarly for option2, simply cd into option2 and run
node app.js from there.
Next, navigate to one of the following URLs:
Note: The Jade layout files for Option 2 can be found in the /views folder.
This option uses Ruby, Sinatra and Haml and requires that you have at minimum Ruby and bundler installed as a prerequsite.
git clone https://github.com/addyosmani/backbone-boilerplates.git cd option3 bundle install ruby app.rb
Finally, navigate to
Note: The Haml layout files for Option 3 can be found in the /views folder.
##Thanks and future plans
I would like to extend my thanks to Chris Riccomini for his Weapon of Choice project. It served as the inspiration and a partial base for this repo, which I plan on expanding to cover other setups such as Backbone + Socket.io, Backbone + SocketStream and more.
Backbone Boilerplates is a project that was created to stub further examples for my creative-commons book Backbone Fundamentals. The idea is to create further applications for the yet to be written RESTful/backend sections of the book, which have been repeatedly requested on the issue tracker.
If you notice any major issues, please let me know about them and I'll do my best to fix them up right away.