此包已被弃用且不再维护。未建议替代包。

PHP 5.3 的路由和请求/响应处理微框架

v2.7.0 2014-07-08 23:44 UTC

README

一个轻量级的库,用于处理PHP5.3中的请求和响应。提供基于闭包的路由、控制器和模板化基础设施。

名字来源于拉丁语,Cogito ergo sum。“我思故我在”。

安装

Ergo 被设计得易于安装和集成。

$ pear channel-discover pearhub.org
$ pear install pearhub/Ergo

或者,将其作为子模块检出,并在类目录上使用自己的类加载器。

基本用法

require_once('Ergo/ergo.php');

Ergo::router()->connect('/helloworld', 'helloworld', function() {
	return Ergo::template('helloworld.tpl.php', array(
	  'greeting'=>'Hello World'
	));
});

Ergo::router()->connect('/*', 'any', function() {
	throw new \Ergo\Http\NotFound("Not implemented yet");
});

如何开发

对于运行,Ergo 没有外部依赖。对于开发,使用 Composer 来拉取 SimpleTest 作为依赖。

通过 Composer 安装依赖

$ composer install --dev

运行测试套件

$ phpunit
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /home/vagrant/ergo/phpunit.xml.dist

...............................................................  63 / 100 ( 63%)
.....................................

Time: 0 seconds, Memory: 11.25Mb

OK (100 tests, 269 assertions)

状态

被用于包括 99designs.com、flippa.com、learnable.com 和 sitepoint.com 在内的多个高流量生产网站。