PHP code example of poolbang / captcha

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

    

poolbang / captcha example snippets


return [
    'default'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'math'      => true, //Enable Math Captcha
    ],
    // ...
];


    /**
     * @RequestMapping(route="captcha")
     * @return \Swoft\Http\Message\Response|static
     */
    public function image(){
       $captcha =  Captcha::create();
       echo $captcha->getKey().PHP_EOL; // generate captcha code
        return context()->getResponse()->withContent($captcha->getImage()->encode($captcha->getImage()->extension,
            90)->encoded)->withContentType($captcha->getImage()->mime()); // show captcha image
    }