kengoldfarb/underscore_php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kengoldfarb/underscore_php

最新稳定版本:1.0.0

Composer 安装命令:

composer require kengoldfarb/underscore_php

包简介

_php - a lightweight MVC structure. Designed to provide the basics or allow you to change it. Emphasis on speed with routing done at the webserver (apache) layer.

README 文档

README

Installation

Composer

The easiest way to install is by using Composer

In your composer.json file:

{
	"require": {
		"php": ">=5.3.0",
		"kengoldfarb/underscore_php": "1.*",
	}
}

Alternately, you can just Download the source

Getting Started

This framework follows the MVC pattern with all routing occuring at the webserver level.

The best way to enjoy _PHP is by using it in conjunction with _Libs which can be installed by composer (this is there by default)

{
	"require": {
		"php": ">=5.3.0",
		"kengoldfarb/underscore_libs": "1.*",
	}
}

Controllers (and basic routing)

Creating friendly urls is easy.

http://localhost/ maps to controllers/defaultController.php [action=index]

http://localhost/hellothere maps to controllers/defaultController.php [action=hellothere]

http://localhost/lists maps to controllers/listsController.php [action=index]

http://localhost/lists/add-list maps to controllers/listsController.php [action=add-list]

and so on...

Just check out controllers/defaultController.php for examples.

For custom routing check out the .htaccess file and the nginx example config file

Models

Models should be created in models/ and then used normally

require_once _MODELS . 'MyModel.php';
$myModel = new MyModel();

Views

Views are included by the controller. This allows you a lot of flexibility to create layouts as you see fit.

include _VIEWS . 'header.php';
include _VIEWS . 'myview.php';
include _VIEWS . 'footer.php';

See the views/ directory and defaultController.php for examples

Config

Environments

Environment specific configuration options can be defined in files located in src/env/

Mapping your server name to an environment happens in src/config/environments.php

Constants

_PHP defines some handy constants that can be used throughout your code.

_WEBROOT The full path to the web root directory (/path/to/project/src/www)

_MODELS The full path to the web root directory (/path/to/project/src/www/models)

_CONTROLLERS The full path to the web root directory (/path/to/project/src/www/controllers)

_VIEWS The full path to the web root directory (/path/to/project/src/www/views)

Versioning

You can set a version in the src/config/version.php file. This is particularly useful for cache busting.

Anything that comes in with a version number will be routed to the corresponding location.

For example:

http://local.underscorephp.com/v1.2.3/css/bootstrap-responsive.css is the same as http://local.underscorephp.com/css/bootstrap-responsive.css

http://local.underscorephp.com/v1.2.3/underscore_php is the same as http://local.underscorephp.com/underscore_php

Webserver Config

Check out the .htaccess file for apache. Nginx coming soon...

License

GNU General Public License Version 3

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: GNU
  • 更新时间: 2013-02-02