PhalApi学习笔记

1.参数配置规则,以及API文档解析规则配置

<?php
/**
 * 默认接口服务类
 *
 * @author: dogstar <[email protected]> 2014-10-04
 */

class Api_Default extends PhalApi_Api {

	public function getRules() {
        return array(
            'index' => array(
                'username' 	=> array('name' => 'username', 'default' => 'PHPer','min' => 6,'max' => 10,'require' => true ),//在这里配置请求参数,以及参数的一些规则
            ),
        );
	}
	
	/**
	 * 默认接口服务 接口文档显示的API名字
	 * @return string title 标题
	 * @return string content 内容
	 * @return string version 版本,格式:X.X.X
	 * @return int time 当前时间戳
	 * @desc这里是对怎么使用这个API的描述
	 */
	public function index() {
        return array(
            'title' => 'Hello World!',
            'content' => T('Hi {name}, welcome to use PhalApi!', array('name' => $this->username)),
            'version' => PHALAPI_VERSION,
            'time' => $_SERVER['REQUEST_TIME'],
        );
	}
}


猜你喜欢

转载自blog.csdn.net/u014034079/article/details/56843801