2017 © Pedro Peláez
 

library code

code make in laravel

image

sjzlai/code

code make in laravel

  • Friday, April 20, 2018
  • by sjzlai
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 80 % Grown

The README.md

效果预览

效果, (*1)

安装

确保你安装了 Composer:, (*2)

composer require sjzlai/code

配置

1.打开laravel项目中 config\app.php, (*3)

2.找到providers数组,在最下面添加Sjzlai\Code\CodeServiceProvider::class 注意 “”, (*4)

生成验证码

<?php

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() 为获取验证码的方法
    }
}

设置路由文件

设置验证码路由, (*5)

routes/web.php, (*6)

<?php

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

视图调用

<img src="/imgCode" art="点击更换"/>, (*7)

The Versions

20/04 2018

dev-master

9999999-dev

code make in laravel

  Sources   Download

MIT

by Avatar sjzlai

20/04 2018

1.0

1.0.0.0

code make in laravel

  Sources   Download

MIT

by Avatar sjzlai