Skip to content

jerrylsxu/YiiBackbone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YiiBackbone

Introduction

YiiBackbone is a sample blog web application build using Backbone.js and Yii. The source of this project can be used to kick-start other Backbone.js projects or serve as reference point on using Backbone.js.

Requirements

  • Apache 2 Web Server
  • MySQL 5.1+ with InnoDB support.
  • PHP 5.3+ configured with the following extensions:
    • PDO
    • PDO MySQL driver
    • GD2
    • Mcrypt
    • CUrl
    • Imap

Installation

You can get the source files from:

$ git clone git@github.com:clevertech/YiiBackbone.git

And load git submodules:

$ cd YiiBackbone
$ git submodule update --init

Make directories protected/runtime and assets writable by the webserver.

$ chmod 0777 protected/runtime
$ chmod 0777 assets/

Create a main-local.php file inside /protected/config with something like the following (uncomment the below lines if want to integrate the Gii code generation feature of Yii for generating php models, controllers, CRUD, etc. in your development environment):

<?php
return array(
//	'modules' => array(
//		'gii' => array(
//			'class' => 'system.gii.GiiModule',
//			'password' => 'giiPassword',
//		),
//	),
	'components' => array(
		'db' => array(
			'connectionString' => "mysql:host=127.0.0.1;dbname=yii_backbone",
			'username' => 'root',
			'password' => '',
		),
//		'urlManager' => array(
//			'rules' => array(
//				// GII patterns
//				'gii' => 'gii',
//				'gii/<controller:\w+>' => 'gii/<controller>',
//				'gii/<controller:\w+>/<action:\w+>' => 'gii/<controller>/<action>',
//			)
//		)
	),
);

Run the migrations:

$ cd protected
$ php yiic.php migrate

Optional - if you chose to enable the Gii code generation tool, then you can use this url and password

URL:      http://hostname/path-to-yiibackbone/gii (for example: http://localhost/YiiBackbone/gii)
Password: giiPassword

Technology Stack

Here are some current components of YiiBackbone and links to relevant resources.

Name : Path : Docs URL

Please note that some JS libs are converted to AMD format so that they can be loaded asynchronously. If a lib is not defined as AMD module it will not load properly. For further information on AMD please see http://requirejs.org/docs/whyamd.html

For converting existing libraries into AMD libraries please see https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries

Testing

For BDD on YiiBackbone we are using:

You need to install /app/package.json using NPM to enable Cucumber.js. Follow the instructions on Cucumber.js's docs site above.

Code Style Guide

Indent

For JavaScript, CSS, HTML files we use only spaces, and indent 2 spaces at a time. And for PHP files we follow Yii style with 1 tab indentation.

Backbone Resources

We recommend going through the following resources for some advanced concepts on using Backbone.js.

Also take a look at Marionette.Application and Marionette.Region components of great Backbone.Marionette framework:

Gotchas

One problem that you may encounter while working with RequireJS is circular dependencies. Please see http://requirejs.org/docs/api.html#circular

Known Bugs

Architecture

YiiBackbone's architecture is divided into two obvious parts. The server and the client.

The server-side is handled by Yii. Yii is used to provide the DB manipulations with the migrations, emailing, ActiveRecord, RESTful resources, password encryption, secure cookie over SSL creation, console commands and few other things. All server side files can be found under "/protected".

The actual app is build entirely with JS on the client-side. All files can be found under "/app".

The application consists of the following parts ("/app/js")

  • models
  • collections
  • views
  • templates
  • helpers
  • libs
  • app.js
  • router.js
  • main.js

Authors

Thanks

CleverTech for supporting this OpenSource project.

License

The MIT License

Copyright (c) 2012 CleverTech

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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 66.3%
  • PHP 27.4%
  • HTML 3.2%
  • CSS 2.7%
  • Ruby 0.1%
  • Gherkin 0.1%
  • Other 0.2%