PHP code example of muyilongh / owl-wechat-user

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

    

muyilongh / owl-wechat-user example snippets


// 在 app/Exceptions/Handler.php 中添加以下代码
use Jiannei\Response\Laravel\Support\Traits\ExceptionTrait;

use ExceptionTrait;

// 引入以后对于 API 请求产生的异常都会进行格式化数据返回
// 要求请求头 header 中包含 /json 或 +json,如:Accept:application/json
// 或者是 ajax 请求,header 中包含 X-Requested-With:XMLHttpRequest;


use Jiannei\Response\Laravel\Support\Format;
use Jiannei\Response\Laravel\Support\Traits\JsonResponseTrait;

class Controller extends BaseController
{
    // use 这个 trait
    use JsonResponseTrait

    // 添加 formatter 属性
    protected $formatter;

    public function __construct()
    {
        // 初始化 formatter
        $this->formatter = new Format();
    }
}
bash
php artisan vendor:publish --provider="Jiannei\Response\Laravel\Providers\LaravelServiceProvider"