Asf_Route_Pathinfo

基于 HTTP Query String 做路由解析, 默认支持协议

入口配置

asf.dispatcher.route 项无需配置, Asf_Route_Pathinfo 默认路由协议

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
    )
);

$handle = new Asf_Application($configs);
$handle->run();

Example #1 URL请求方式例子

/* path: /data/www/api/services/User.php */

curl domain.cn/index/user/list
curl domain.cn/index/user/list/username/zhangsan/nickname/haha

/* path: /data/www/api/services/Index.php */

curl domain.cn/index/index

Example #2 不区分大小写

/* path: /data/www/admin/services/User.php */

curl domain.cn/Admin/UsEr/LIST
curl domain.cn/admiN/UsER/LisT/username/zhangsan/nickname/haha

/* path: /data/www/admin/services/Index.php */

curl domain.cn/aDMin/Index/IndEx

Asf_Route_Dot

基于 HTTP Query String 做路由解析

入口配置 1

  1. asf.dispatcher.route.dot_name 默认值为字符串 method
<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
        'dispatcher' => array(
            'route' => array(
                'type' => 'dot',
            )
        )
    )
);

$handle = new Asf_Application($configs);
$handle->run();

入口配置 2

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
        'dispatcher' => array(
            'route' => array(
                'type' => 'dot',
                'dot_name' => 'method',
            )
        )
    )
);

$handle = new Asf_Application($configs);
$handle->run();

Example #1 URL请求方式例子

/* services/index.php */

curl "domain.cn/index.php?method=index.index.index"
curl "domain.cn/index.php?method=index.index"
curl "domain.cn/index.php?method=index.index&username=zhangsan&nickname=haha"

/* services/index/user.php */

curl "domain.cn/index.php?method=index.user.str"

Asf_Route_Query

基于 HTTP Query String 做路由解析

  1. asf.dispatcher.route.module_name 默认值为字符串 m
  2. asf.dispatcher.route.service_name 默认值为字符串 s
  3. asf.dispatcher.route.action_name 默认值为字符串 a

入口配置 1

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
        'dispatcher' => array(
            'route' => array(
                'type' => 'query',
            )
        )
    )
);

$handle = new Asf_Application($configs);
$handle->run();

入口配置 2

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
        'dispatcher' => array(
            'route' => array(
                'type' => 'query',
                'module_name' => 'm',
                'service_name' => 's',
                'action_name' => 'a',
            )
        )
    )
);

$handle = new Asf_Application($configs);
$handle->run();

Example #1 URL请求方式例子

/* services/index/user.php */

curl "domain.cn/index.php?m=index&s=user&a=str"
curl "domain.cn/index.php?m=index&s=user&a=list&username=zhangsan&userpass=123456"
curl "domain.cn/index.php?m=index&s=user&a=add&username=zhangsan&userpass[]=123456&userpass[]=56789" -g