带缓存的PHP路由库:Ham

jopen 11年前

Ham 是一款轻量级的路由框架,利用缓存来提升速度。把任何 I/O 相关的东西缓存进 XCache/APC。要求 PHP 5.3+ 和 XCache 或者 APC。

示例代码:

require '../ham/ham.php';    $app = new Ham('example');  $app->config_from_file('settings.php');    $app->route('/pork', function($app) {      return "Delicious pork.";  });    $hello = function($app, $name='world') {      return $app->render('hello.html', array(          'name' => $name      ));  };  $app->route('/hello/<string>', $hello);  $app->route('/', $hello);    $app->run();

目标

  • Make pretty much anything I/O related cached with XCache/APC (whichever is installed) in order to prevent excessive disk usage or path searching on lots of requests.
  • Provide a succinct syntax that means less magic and less code to read through and learn, without compromising speed or code length, by using native PHP methods and features.
  • Promote a simple, flat way of building applications that don't need massive levels of abstraction.
  • Encourage use of excellent third-party libraries such as Doctrine to prevent developers writing convoluted, unmaintainable code that people like me have to pick up and spend hours poring over just to get an idea of what on earth is going on.
  • Define and document development patterns that allow for new developers to get up to speed quickly and write new code that isn't hacky.

项目主页:http://www.open-open.com/lib/view/home/1388453653859