PHP code example of weikaiii / code

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

    

weikaiii / code example snippets




namespace App\Http\Controllers;

use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function imgCode()
    {
         $app = app('code');//可以使用app全局函数 参数为code 生成code实例
         $app->make();    //make() 为生成验证码的方法
         //$app->fontSize = 16;// 设置字体大小        
         //$app->num = 4;// 设置验证码数量
         //$app->width = 100// 设置宽度
         //$app->height = 30// 设置宽度
         //$app->font = ./1.ttf // 设置字体目录
         return $app->get(); //get() 为获取验证码的方法
    }
}




Route::get('/', function () {
    return view('welcome');
});
Route::get('imgCode',"IndexController@imgCode");