PHP code example of cat-sys / cat-api-app

1. Go to this page and download the library: Download cat-sys/cat-api-app library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cat-sys / cat-api-app example snippets


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

// 获取连接池
$redis_pool = PoolManager::getInstance()->get('redis_master');

// 发起请求
$redis_result = yield $redis_pool->pop()->get('cache');



// 获取连接池
$mysql_pool = PoolManager::getInstance()->get('mysql_master');

// 发起请求
$sql_result = yield MySQLStatement::prepare()
    ->select("Test",  "*")
    ->limit(0,2)
    ->query($mysql_pool->pop());


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

bash
php run.php start
bash
php run.php start -c release