PHP code example of mjy191 / tools

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

    

mjy191 / tools example snippets

 artisan vendor:publish --provider="Mjy191\Tools\ServiceProvider"


return [
    // 接口签名appid和appkey,不同路由可以有不同的签名
    'ak' => [
        'api'=>[
            'appId'=>'xxxx',
            'appKey'=>'xxxx',
        ],
        'admin'=>[
            'appId'=>'xxxx',
            'appKey'=>'xxxx',
        ],
    ],
    //密码加盐前缀
    'preSalt' => 'xxxx',
     //密码加盐后缀
    'postSalt' => 'xxxx',
];

namespace App\Exceptions;

use Mjy191\Tools\Tools;
use Exception;

class ApiException extends Exception
{
    /**
     * 转换异常为 HTTP 响应
     *
     * @param \Illuminate\Http\Request
     * @return \Illuminate\Http\Response
     */
    public function render($request)
    {
        return response()->json(Tools::returnData(null,$this->getCode(),$this->getMessage()))->setEncodingOptions(JSON_UNESCAPED_UNICODE);
    }
}