Database interaction with codeigniter and backbone.js - codeigniter

I am trying to learn backbone.js to make a web application.This is my first time with a javascript framework and I am fairly confused with some of the stuff.
I have been developing in codeigniter for a while so I do have a understanding of the MVC architecture.
My question is how do I get the data from the backbone.js front end to my codeigniter controller and save it in the database. for example to implement a simple login/register functionality with CI and backbone, how should I proceed. If anyone can guide me step step then that would be great or point me to the right resource. Thank you.
PS: I know that I have to implement a REST api with my codeigniter but I don't know how? so if someone can provide a basic controller example it'd be really helpful.

Here's a tutorial to use the API mentioned in the above reply (by the author of the library himself)
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/

Related

What is the correct approach to learn Codeigniter?

In the last 3 months, i have learnt html, css, js and php and now i'm trying to learn Framework Codeigniter. My teacher gave me a rough idea abt MVC and asked me to download a project made on codeigniter from internet and edit it.
I downloaded a login form project and tried to read it. But i'm still kind of confused how everything works. i hv 2 questions:
What is the correct approach to learn codeigniter?
In how many days one can learn codeigniter? (i practice around 6-7 hrs a day)
The best way to learn codeigniter is to read the manual of codeigniter
Because, codeigniter framework is so much popular for their well formatted and clean documentation.
Or you can check this for beginner level tutorial
Or if you want to learn codeigniter by doing practical projects then you can follow this link
I learned CI over a weekend using this technique.
Start with simply setting up a 2 page site.
Home and About Us.
Pass simple string variables from the controllers to the views.
Next, bring a model into it.
Make a method in your model that returns some plain text, to the controller and finally to the model.
Next, make the model actually make a request to your database and return the result to the constructor then view.
After that try these:
write a helper function
Try making a basic route
Log a debugging message
upload a file from a form using the upload library
That's a good grounding in CI
Keep in mind Codeigniter is no longer in development also.
If your keen on sticking with PHP, you might want to check out the similar active project called "Laravel" after getting the hang of CIs very simple MVC structure.
Good luck!
the common way is read their manual and follow the guide, the another approach is search youtube for codeigniter turial, there are many good tutorial out there and easy to follow for example here is my result in the first place for keyword "codeigniter tutorial"
https://www.youtube.com/watch?v=BP9NRZXOvIw&list=PLIQyGVrcLTeXsq37O7IBGaUwu6xEwqBWV&index=1

Front End Frameworks for RESTful backend

I am developing a RESTful backend using Spring framework. All the services are accessible through HTTP request methods (GET, POST, PUT, DELETE).
Could you please tell me what can the best combination of frameworks for front end?
Is it best to use SpringMVC or some other framework like Backbone is good enough?
If I am using SpringMVC for REST backend and also SpringMVC for front end then won't it be extra work doing same things again first for backend then for front end?
And most important I am confused about how can do the session management using front end?
Any help will be appreciated!
If you are looking into to make a SPA (Single Page App) make sure that you take a look at AmpersandJS -> http://ampersandjs.com/
Templates
Since you said "server-side" GUI, maybe you are thinking more along the lines of a template engine for creating HTML? This isn't really restful, but can be MVC like if you are forwarding from your Controller classes.
But PLEASE keep in mind that it would be a very BAD idea to try and generate XML or JSON data for consumption by RESTful clients (ajax) with either of these. Just say no to JSON creation from a template engine!
JSP is pretty much the standard for Java EE at the moment, or is most widely used. All you need is a compliant server, such as Tomcat/Jetty.
http://www.oracle.com/technetwork/java/javaee/jsp/index.html
Thymeleaf It looks a lot cleaner than JSP, and has the added benefit of not allowing all the pitfalls that can happen with a JSP (and there are a lot).
http://www.thymeleaf.org/
JavaScript:
When you say you are creating a RESTful backend, most people would make the conclusion (and rightfully so) that you are trying to develop a JavaScript MVVM client/GUI.
Kendo UI has a complete set of GUI widgets and MVVM framework that is specifically designed to work with a RESTful backend. But it's a paid for API.
http://www.telerik.com/kendo-ui
YUI3 (Yahoo User Interface) has a variety of widgets as well, and I've seen a lot of jobs requesting this. It has the advantage of being free/OSS as well. Older version are deprecated.
https://github.com/yui/yui3/wiki
knockout.js has been my favorite for MVVM engines that I've actually had experience working with. And it's simple to learn, in my opinion.
http://knockoutjs.com/
Angular.js Also free/oss, and works well with other GUI APIs.
https://angularjs.org/
I would suggest you to consioder Sencha Ext JS for front-end, it is one of the best framework and will work with RestFul back-end.
this is a good question, but I don't think there is a server-side framework out there specifically built to use a REST server backend. I think you could use Spring-MVC / Spring-Boot to get a good headstart, but you might also want to look into Rails or other Ruby any other modern web framework technology.

Using Extjs4 in the frontend

I've been a big fan of BackboneJS (and still am) until I discover Extjs4 in my new Job. I can only tip my hat for what it can do! Now my question is whether it is possible (or recommanded) to use Extjs in the frontOffice without using its components. I only want to take advantage of both the MVC architecture that it offers and the module loader feature. With backbone, I use AMD and require Js for module loading and it's a pain and very hard to generate production build.
I'm wondering also if Extjs will have a JavaScript routing engine in the next version.
Your advice will be very appreciated,
Thank You.
Sound great that you are BackboneJS fan. To answer your question... You can use ExtJS anywhere in web application which makes end-user an real cutting-edge tech. You already worked in Backbone and learning ExtJS. First consider which one you need to use for your application, either BackboneJS or ExtJS, because both are advance concept of JS.
For your second question, ExtJS use well structured MVC pattern over BackboneJS. You dont need to migrate to ExtJS if you can able to create custom Controller(Getting components reference) control in BackboneJS. My suggestion is to go with ExtJS.
ExtJS sencha forum is really good one to learn more over their component reference and raise bugs and request for any new javascript routing engine as you mentioned.

How to use Google Map API in CodeIgniter?

How to get started with CodeIgniter and Google Maps API.
I've got a CodeIgniter library specifically for this purpose. You can find more information about it here:
http://biostall.com/codeigniter-google-maps-v3-api-library
A few demos of what can be acheived using the library:
http://biostall.com/demos/google-maps-v3-api-codeigniter-library/
Give me a shout if you have any questions or need any help :)
Enjoy!
CodeIgniter is a backend (server-side) framework. Google Maps API is a frontend (client-side) library. There isn't really any specialized knowledge you need to know about CodeIgniter to get Google Maps working, other than being able to render a view. The question is somewhat flawed in that you assume one depends on the other, when in reality, they are very much decoupled.
The question is similar to how do i get jquery working with codeigniter?...
Reading the CodeIgniter documentation would be a start to understanding how to echo HTML and JavaScript to the browser. The rest is almost entirely client-side JavaScript programming.

What is the best method for creating an API using MVC3

I am using mvc3 and I want to create an API with the site.
MVC makes it really easy to return json from the controller which I know how to do.
I want to use a subdomain for the api something like http://api.mydomain.com
I have a few questions
Do I create an area for api or just place the controller and model in the root?
How can I point to the subdomain so the url is api.mydomain.com not mydomain.com/api
What is the best way to version the api? do I just create a new controller for each version e.g. V1Controller,V2Contoller etc etc
Any suggestions would be really helpful.
Thanks for your help
I have recently used ServiceStack, I really like working with it, you should take a look
http://www.servicestack.net/

Resources