PHP code example of wxm / ddoc

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

    

wxm / ddoc example snippets


    Wxm\DDoc\DDocServiceProvider::class
    

    // 本地环境注册
    if ($app->environment('local')) {
        $app->register(Wxm\DDoc\DDocServiceProvider::class);
    }
    

/**
 * @Resource("登录令牌", uri="/token")
 */
class AuthController extends Controller
{
    /**
     * 获取令牌
     *
     * > 通过手机号和密码获取会话`token`即登录凭证.
     * > 需要认证的请求请携带此 Authorization 头
     * >
     * > Authorization:Bearer {token}
     * > 
     *
     * @Post("/")
     * @Versions({"v1"})
     * @Response(200, body={"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkueHkudGVzdFwvc2Vzc2lvbiIsImlhdCI6MTU0NTIxNjM5OSwiZXhwIjoxNTQ1MjE5OTk5LCJuYmYiOjE1NDUyMTYzOTksImp0aSI6Im9pZjV4WTNqS2JkbEhzVmQiLCJzdWIiOjEsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.p3oAVkAxSCxTug5s6168N-ccfuCCywGDFiJ0b9zCXq8","token_type":"bearer","expires_in":3600})
     * @Parameters({
     *      @Parameter("phone", type="integer", 3ViIjoxLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.qBCL-EfGYRnlxPZerpHpD9HVumjf89fVa2CBoXoFSvI","token_type":"bearer","expires_in":3600})
     */
    public function refresh()
    {

    }
}
shell
    php artisan vendor:publish --provider="Wxm\DDoc\DDocServiceProvider" --force
    
shell
    php artisan serve
    
nginx
location ~ /ddoc/ {
  auth_basic "Authorized users only";
  auth_basic_user_file .htpasswd;
  try_files $uri /index.php?$query_string;
}