# 增加文件
~~~
增加文件1:application\common\fun\Shorturl.php
增加文件2:application\index\controller\Shorturl.php
增加文件3:application\index\model\Shorturl.php
~~~
# 增加数据表
~~~
qb_shorturls
~~~
# 修改文件
## 修改文件1:application\\route.php
在route.php顶部加入
~~~
Route::group(['name'=>'url','ext'=>'html'], [
    '<id>' =>['index/shorturl/index',['method'=>'get'],['id' => '[0-9a-zA-Z]{6}']],
]);
~~~
## 修改文件2:application\\common.php
在common.php文件最后插入以下两个方法
~~~
if (!function_exists('shorturl')) {
    function shorturl($url=''){
        return request()->domain().'/url/'.fun('shorturl@create',$url).'.html';
    }
}
if (!function_exists('myRands')) {
    //取得随机字符
    function myRands($length = 6, $type = null)
    {
        switch ($type) {
            case 'e':
                $chars = 'abcdefghijklmnopqrstuvwxyz';
                break;
            case 'E':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
                break;
            case 'Ed':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
                break;
                break;
            case 'eE':
                $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
                break;
            case 'd':
                $chars = '0123456789';
                break;
            case 'ALL':
                $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
                break;
            default:
                $chars = 'abcdefghijklmnpqrstuvwxyz123456789';
                break;
        }
        $rand = '';
        for ($i = 0; $i < $length; $i++) {
            $rand .= $chars[mt_rand(0, strlen($chars) - 1)];
        }
        return $rand;
    }
}
~~~
                    
        
    