PHP code example of ginv / ginv

1. Go to this page and download the library: Download ginv/ginv 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/ */

    

ginv / ginv example snippets


'demo' => 'http://localhost:8080/v1/rpc/'

// 获取config/app.php的key为name的配置
config('app.name') 

$db     = db();
        $count  = $db->count('account.count', ['account_uuid' => $account_uuid]);

// config/redis_key.php中
//    'account_info' => 'demo:account_info:%d'
// 下面的$key的值为demo:account_info:1
$id = 1;
$key = redis_key('account_info',$id);

$id = 1;
$key = redis_key('account_info',$id);
$account_info = redis()->do('get',$key);

// 项目的temp目录
base_path('temp')

// dump and die;
dd('111');



namespace api\v1;
use api\Base;

class Blog extends Base
{
    /**
     * 分页获取博客列表
     * @param string $account_uuid 用户uuid
     * @param int    $page 当前页
     * @param int    $limit 每页数量
     *
     * @return array
     */
    public function blogList($account_uuid = '',$page = 1, $limit = 10) {
        $offset = ($page-1) * $limit;
        $db = db();
        $params = [
            'account_uuid' => $account_uuid,
            'limit' => $limit,
            'offset' => $offset
        ];
        $count = $db->count('account.count',$params);
        $list = $db->query('account.list',$params);
        $account_uuid_array = array_column($list,'account_uuid');
        // 获取用户的用户名
        $account_array = $this->rpc('demo_account','account')->call('accountList',$account_uuid_array);
        foreach ($list as &$item) {
            foreach ($account_array as $account) {
                if ($item['account_uuid'] == $account['account_uuid']) {
                    $item['account_name'] = $account['account_name'];
                }
            }
        }
        $result = compact('count', 'list');
        return $this->set($result)->response();
    }
}