Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CatsSystem/CatApiApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

12 Commits

Repository files navigation

介绍

Swoole Http API 应用

依赖

CatApi

安装

Composer安装

composer create-project --no-dev cat-sys/cat-api-app {project_name}

注: 测试阶段请使用 composer create-project --stability=dev --no-dev cat-sys/cat-api-app {project_name}命令安装

异步API

异步Task

// 实例化异步任务
$task = new AsyncTask('TestTask');
// 发送任务请求
$result = yield $task->test_task(1, "test", [1, 2, 3 ]);

Redis访问

// 获取连接池
$redis_pool = PoolManager::getInstance()->get('redis_master');
// 发起请求
$redis_result = yield $redis_pool->pop()->get('cache');

MySQL访问

// 获取连接池
$mysql_pool = PoolManager::getInstance()->get('mysql_master');
// 发起请求
$sql_result = yield MySQLStatement::prepare()
 ->select("Test", "*")
 ->limit(0,2)
 ->query($mysql_pool->pop());

Http请求

$http = new Http("www.baidu.com");
yield $http->init();
$result = yield $http->get('/');

环境支持

配置

配置文件均在config目录下

运行

在项目目录下,执行以下命令

php run.php start

进入DEBUG模式。

执行以下命令

php run.php start -c release

指定配置文件目录

请求方式

请求使用Http POST方式, 参数格式为JSON编码, Content-Type限定为application/json

访问地址格式为: http://ip:port/module/controller/method

module为模块名 controller为控制器名 method为方法名

路由配置在route.php配置文件中

About

Cat Http Api Application

Resources

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /