PHPackages                             enovision/slim-captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. enovision/slim-captcha

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

enovision/slim-captcha
======================

Slim Captcha adapted from CodeIgniter's captcha helper

0.2.2(8y ago)11571MITPHPPHP ^5.5.9 || ^7.0

Since Oct 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/enovision/slim-captcha)[ Packagist](https://packagist.org/packages/enovision/slim-captcha)[ Docs](https://github.com/enovision/slim-captcha)[ RSS](/packages/enovision-slim-captcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Slim Captcha
============

[](#slim-captcha)

This easy to use captcha package is based on the captcha helper from CodeIgniter (Ellislab).

Installing
----------

[](#installing)

Use Composer to install Slim Captcha into your project:

```
composer require enovision/slim-captcha

```

or clone it from github

```
git clone https://github.com/enovision/slim-captcha

```

Requirements
------------

[](#requirements)

- akrabat/rka-ip-address-middleware

Usage With Slim 3
-----------------

[](#usage-with-slim-3)

### Requirements

[](#requirements-1)

- the 'gd' extension (gdlib) has to be loaded (for creating the image)
- the `img_path` as a setting has to be set to a folder in the public folder like f.e. `captcha` (this folder has to be writeable (chmod 775)

    like: $\_SERVER\['DOCUMENT\_ROOT'\] . '/captcha/' (as is folder in public\_html/captcha or private\_html/..)
- the img\_url have to be set in the settings

    like: 'http(s)://' . $\_SERVER\['SERVER\_NAME'\] . '/captcha/'

### Database table 'captcha'

[](#database-table-captcha)

The following table is required to make this package successful. Below you find the code for MySQL, but you can also implement your own requirement. All the database activity is done with callback functions, so you can have your own implementations work as well.

```
CREATE TABLE `captcha` (
  `captcha_id` BIGINT(13) UNSIGNED NOT NULL AUTO_INCREMENT,
  `captcha_time` INT(10) NOT NULL,
  `ip_address` VARCHAR(45) NOT NULL,
  `word` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`captcha_id`),
  INDEX `word` (`word`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=0;

```

Sample callbacks with Eloquent ORM in Slim 3 as can be found in the settings file:

```
