PHP code example of ybscript / swoole-buried
1. Go to this page and download the library: Download ybscript/swoole-buried 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/ */
ybscript / swoole-buried example snippets
$ php init
$ php buried -t tcp
$ php buried -t udp
class HomeController
{
public function onIndex($info)
{
$sort = json_decode($info, true)['sort'] ?? 1;
$res = UserModel::query()->where('sort', (int)$sort)->first()->toArray();
//组件使用 所有组件都可以使用Yb::$app取获取使用 单例模式
// $redisContent = Yb::$app->redis->get('test');
Yb::$app->log->info('test', 'this is a error record info fro test');
return $res;
}
}