PHP code example of larva / easysdk

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

    

larva / easysdk example snippets


$options = [
    //Http 配置
    'http' => [
        'max_retries' => 1,//失败重试次数
        'retry_delay' => 500,//重试延迟
        //'log_template' => '>>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}',//日志模板
    ],
    // 日志配置
    'log' => [
        'default' => 'dev', // 默认使用的 channel,生产环境可以改为下面的 prod
        'channels' => [
            // 测试环境
            'dev' => [
                'driver' => 'single',
                'path' => 'easysdk.log',
                'level' => 'debug',
            ],
            // 生产环境
            'prod' => [
                'driver' => 'daily',
                'path' => 'easysdk.log',
                'level' => 'info',
            ],
        ],
    ],
];
$app = new \Larva\EasySDK\ServiceContainer($options);
// 一般是 继承 \Larva\EasySDK\ServiceContainer 类来扩展出API