Ember with Yii REST backend,demo application.
This is a very simple Contacts application.You can list,view,edit,create and delete contacts. I have based my demo application on Dan Gebhardt's demo application for Rails. I have added a login screen, AMD with require.js, and connected to a Yii backend REST API written by Antonio Ramirez (slightly modified) for his YiiBackBoneBoilerplate application. The process of putting all this together helped me understand and appreciate Ember.js as a very useful tool for building heavy client side web applications.All the logic is laid out in javascript,with Ember.js framework wiring it all up.The persistence layer is provided by ember-data.js which provides a default REST adapter out of the box.Of course it's possible to override the defaults and code the persistence layer of your choice. With ember.js you can utilize separation of concerns (SoC) in your project, divide the logic into models,views,controllers, use a folder structure that reflects MVC and therefore acquire huge benefit in terms of scaling and maintaining your application in an organized structure.
Clone the git repo - git clone git://github.com/drumaddict/ember-yii.git - or download it
To install,follow these steps.
Advice on & Instruction in the Use Of Ember.js. This is an extended ember tutorial that I suggest in order to understand ember thoroughly. It also mentions backbone and how it compares with ember,very useful if you are still overwhelmed and stuck with the choice of a js framework.
I have not investigated every possible js framework out there.I did look into backbone though. I liked the simplicity and good documentation,but it lacks a well defined structure.Ofcourse it is possible to overcome this with additional backbone libraries /dependencies like Backbone Marionette, but to me this is not an attractive idea,as you have to keep all these additions in sync with backbone,as the codebases evolve. Also I am not too keen on having to think about event binding cleanup,and this is something to consider when coding with backbone. Ember on the other hand,features a clear MVC separation of concerns.Binding data to views is automatic,just declare controllers and their associate views, and every time data changes,views update automatically without explicitly writing any code.I have a background in Flex Actionscript Framework and coding js with ember sometimes felt a lot like flex. For your research on js frameworks ,I suggest TODO MVC.Helping You Select an MV* Framework..
Total 4 comments
Thanks for this wiki. I'm trying to do the same thing with Dojo Toolkit.
Thanks for giving us some insights into Ember.js. I thought about using it in a little project of mine and I actually came to the same conclusion regarding the differences between Ember.js and Backbone.js. I've heard people comparing it with Rails/Sinatra (or to stay in the PHP ecosystem - Yii/Slim). It enforces you to do things in a certain way, but I like this approach as it tends to free you from unnecessary boilerplate code
You may have seen a session configuration in config/main.php file,but this session refers to the rest of the website,not the one-page ember application.No state is stored on the server,the login just asks for credentials from the server,the server responds and the client stores the respond in a variable in application_controller (loggedin variable).Of course this may not be best practice, but don't forget this a demo.In addition I think in a REST situation, every request to the server to ask for data should somehow contain authentication in the form of a signature(calculated from credentials),I did not implement this,since -again- this is just a demo for ember.One thing is for sure,no application state is stored on the server,so no stateless principle is violated.
Sorry if I got it wrong, I just had a quick look in the code, and I'm wondering if you are using the session in the server, which breaks the stateless principle of RESTful web services.
Leave a comment
Please login to leave your comment.