最新版本:V1.2.2 开源地址:https://github.com/sasou/php-gene 做者:sasou 文档地址:http://php-gene.com/doc
Gene 是一个灵活、强大、简单、高效的c扩展框架。经过精心的设计与高效的技术实现,配合数据库、缓存等类库,带来新的开发体验。php
对于gene应用,能够遵循相似下面的目录结构,熟悉后能够自定义目录结构.
app
├─Cache
│ └─Views
├─Ext
│ ├─Com
│ │ ├─Cache
│ │ ├─Db
│ │ ├─Queue
├─Config
├─Controllers
│ └─Admin
├─Models
│ ├─Admin
└─Views
├─admin
└─webgit
入口文件是全部请求的入口, 通常都借助于rewrite规则, 把全部的请求都重定向到这个入口文件github
define('APP_ROOT', __dir__ . '/app/'); $app = new \Gene\Application(); $app ->load("router.ini.php") ->load("config.ini.php") ->run();
能够配置http请求方式(get,post,put,patch,delete,trace,connect,options,head),配置路由处理函数:回调函数、类的方法(格式className@methodName)。web
$router = new \Gene\Router(); $router->clear() ->get("/", "\Controllers\Index@run") ->error(404,function() { echo " 404 "; }) ->hook("before", function(){ echo " before "; }) ->hook("after", function($params){ echo " after "; });
配置缓存支持bool、int、long、string、array、常量等数据类型。sql
$config = new \Gene\Config(); $config->clear(); $config->set("_db",array( 'adapter' => 'Pdo\Mysql', 'host' => '127.0.0.1', 'port' => 3306, 'user' => 'root', 'password' => '123456', 'database' => 'demo', 'charset' => 'utf8', 'persistent' => false, )); $config->set("_cache",array( 'adapter' => 'Memcaches', 'servers' => array( 'default' => array( 'host' => '127.0.0.1', 'port' => 8888, 'persistent' => true) ) ));
对于路由配置的\Controllers\Index@run, 控制器的目录是在app目录下的Controllers目录下Index.php文件, Action的命名是run。数据库
namespace Controllers; class Index extends \Gene\Controller { /** * run * @param type $params */ public function run() { echo 'run'; } }
在浏览器输入项目地址,好比:http://localhost/
看到 before run after 输出吧!!!浏览器
注意:若是没有看到before run after, 那么请查看PHP的错误日志, 找出问题在哪里。缓存