2 Star 7 Fork 0

APIJSON/APIJSON-PHP-Simple

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Api.php 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
star 提交于 2018-10-23 17:18 +08:00 . -
<?php
/**
*
*/
namespace apijson;
use Db;
class Api
{
public $param; //数组参数
public $action; //操作
public $allowTable; //允许操作的表
public $allowAction; //允许的操作
public $table; //表名
public $table_prefix
/**
* init
* 不传参数 默认从php://input 读取 json 从url读取 action
* 传参数 则 指定param 与 action
*/
public function __construct($param =null,$action =null)
{
if (!$param) {
$param = file_get_contents('php://input', 'r');
$param = $param ?? [];
}
if(!is_array($param)){
$param = json_decode($param,1);
}
if(!$param){
throw new \Exception("apijson:param empty or invalid", 1);
}
if(!$action){
$action = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'],"/")+1);
if(!in_array($action, ['get','gets','head','heads','post','put','delete'])){
throw new \Exception("apijson:action not exsit or wrong", 1);
}
}
$this->param = $param;
$this->action = $action;
}
/**
* 执行操作
*/
public function exe(){
}
/**
* 解析param
*/
private function parse(){
foreach ($this->param as $k => $v) {
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/APIJSON/APIJSON-PHP-Simple.git
git@gitee.com:APIJSON/APIJSON-PHP-Simple.git
APIJSON
APIJSON-PHP-Simple
APIJSON-PHP-Simple
master

搜索帮助