How to style PHP output?

Is there a Backbone style PHP library?

  • I need to write some Models and Controllers in PHP with similar functionality of those in Backbone.js. I wonder if there is a similar lightweight Backbone style library for PHP, providing similar classes and methods. I've looked at several PHP frameworks but could not find any lightweight one that compactly fits into a file or so. It seems the frameworks are concerned with lots of tasks, e.g. routing, HTML rendering, DB access, which are, generally important, but for my very specific tasks here seems to be an overkill. The main part is creating a modular structure with Backbone/Underscore - like functionality. Of course, I can rewrite the pieces of Backbone code into PHP but I feel a bit like re-inventing the wheel doing it. To make it sound less vague, the exact tasks I am looking into are PHP cron jobs that download files, unzip them, parse line by line, filter and validate, then generate collections and save them in a database. The files are quite large, so I cannot just upload them into memory, manipulate, and dump into DB. I have to use cacheing collections that are being emptied and exported as memory gets full. I would assume those tasks are pretty generic and useful for many other projects, which is why I am asking this question here. Many thanks for your help!

  • Answer:

    I'm not sure if this is exactly what you are looking for but several tutorials and video casts about Backbone has talked about and included the PHP framework Laravel 4 For further reference check this tutorial from NetTuts out: http://net.tutsplus.com/tutorials/javascript-ajax/combining-laravel-4-and-backbone/

Emil Devantie at Quora Visit the source

Was this solution helpful to you?

Other answers

Maybe this won't be answer to your question, but I'll try to explain how I understand what is a backbone.js and what is php. Ok first of all backbone.js is an MVC javascript framework. And in the first place backbone.js is a FRONTEND framework. That means it's not a server side language, you just organising javascript code in a more logical way then it was before. You split code to three parts: M (model - validating data that you receiving) and C (controller - preparing/parsing data which you receiving from model) and V (view - display data which you've got from controller). That's MVC design pattern. In my opinion, the purpose of javascript MVC frameworks (there's plenty of them: backbone.js, angular.js, ember.js) is to split frontend from backend. The backend, is a software that you can request for answer. This can be done via http protocol requests (GET, POST, PUT, PATCH, DELETE methods) or it can be even done by sockets. Anyway, point is you it's a software which send data to you. The frontend is software where you represent a received data. This can be done in multiple formats: you can receive html code and display in browser in human-readable form, you can receive machine-readable format which are comfortable to parse, for example XML, JSON, YAML. This can be even just a byte-stream, which will be parsed by our frontend software. MVC javascript frameworks helps to organise received data. Before that, traditional way was/is  to make same operation with server-side language, which is actually takes much longer time, and much-more complicated logic. If you, for example, receive some data from server, from which you need to generate graphics, this can be done by various frontend software: desktop application which generates vector graphics from their own library (let's that would be a python language, that uses PIL library for this purpose), or you can generate vector graphic on your android phone using some java library, or you want just to generate dynamic vector graphic using adobe flash, or javascript and css. All you would have to do is to write more frontends, and there's no need to overload your backend software with code which generates frontend code. In my opinion it's a wise way to split your software logic. Ok so you've asked for frontend MVC framework alternatives on backend side, for PHP language, so here's what was using: Lightweight MVC frameworks: http://ellislab.com/codeigniter  - Most readable code I've seen in PHP world, really.. this is my favourite framework. http://makoframework.com/ <-- something I quickly googled, worth to try probably. Most popular MVC frameworks: http://cakephp.org/ - one of the oldest MVC framework in php history, personally was using it only when complicated sql queries needed, it's much more easier to construct them in there then in codeigniter, if you project has some complicated search patterns (filtering) http://www.kohanaphp.com/ - one of the most fast progressed framework, that was the only alternative to cakephp if you needed power. Their involved lots of design patterns, and it was poorly documented in my times.. now I think it's a most mature framework in PHP Shttp://symfony.com/- this one came after Kohana, and had some additional features added to view logic. This framework for me is on top with Kohana, cause it's easy to follow, and well documented. http://framework.zend.com/ - one of the main php mvc framework for now. It's a "golden standard" in php world. You can organize your workspace anyway you want. People mostly say it's just an additional library "todo things" easier. I had a negative opinion regarding Zend, because it's a static-classes everywhere with something like: MyCoolClass::WithReallyCoolMethodNameWhichIsKilommeterLong  This makes php code extremely unreadable. http://www.yiiframework.com/- Although this one gains popularity because of "high-perfomance" (it's kind-a funny in nowadays.. we have hiphop tool you know.. perfomance in php - it's a another mif and another topic :) I disliked this framework instantly because of static classes on my time. There's static classes everywhere, but it's actually WAY BETTER than in Zend. At least because class and method names are short. If you fan of static classes this could be a great alternative to CodeIgniter. Some links to new terms for you: http://en.wikipedia.org/wiki/Software_design_pattern http://tomdalling.com/blog/software-design/model-view-controller-explained/ http://en.wikipedia.org/wiki/Front_and_back_ends Maybe some things changed since I migrated to python, but you've got the picture. Hope that helps.

Roman Gorodeckij

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.