Download the PHP package emotionloop/visualcaptcha without Composer
On this page you can find all versions of the php package emotionloop/visualcaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download emotionloop/visualcaptcha
More information about emotionloop/visualcaptcha
Files in emotionloop/visualcaptcha
Package visualcaptcha
Short Description PHP library for visualCaptcha. Still requires you to have the front-end companion.
License MIT
Homepage http://visualcaptcha.net
Informations about the package visualcaptcha
visualCaptcha-packagist
Packagist composer package for visualCaptcha's backend service
Installation with Composer
You need PHP installed with composer.
Run tests
You need PHPUnit installed and then you can run
Usage
Initialization
You have to initialize a session for visualCaptcha to inject the data it needs. You'll need this variable to start and verify visualCaptcha as well.
Where:
$namespace
is optional. It's a string and defaults to 'visualcaptcha'. You'll need to specifically set this if you're using more than one visualCaptcha instance in the same page, so the code can identify from which one is the validation coming from.
Using Cache
You can use a backend Zend-Cache library options to store images on cache and avoid I/O. You'll have to pass options parameter on the constructor as document in https://docs.zendframework.com/zend-cache/storage/adapter/. By default it is disabled and you�ll have to pass true on the constructor on the 5th parameter.
Setting Routes for the front-end
You also need to set routes for /start/:howmany
, /image/:index
, and /audio/:index
. These will usually look like:
Validating the image/audio
Here's how it'll usually look:
visualCaptcha/Session properties
$namespace
, String — This is private and will hold the namespace for each visualCaptcha instance. Defaults to 'visualcaptcha'.
visualCaptcha/Session methods
__construct( $namespace )
— Initialize the visualCaptcha session.clear()
— Will clear the session for the current namespace.get( $key )
— Will return a value for the session's$key
.set( $key, $value )
— Set the$value
for the session's$key
.
visualCaptcha/Captcha properties
$session
, Object that will have a reference for the session object. It will have .visualCaptcha.images, .visualCaptcha.audios, .visualCaptcha.validImageOption, and .visualCaptcha.validAudioOption.$assetsPath
, Assets path. By default, it will be './assets'$imageOptions
, All the image options. These can be easily overwritten or extended using addImageOptions(), or replaceImageOptions( ). By default, they're populated using the ./images.json file $audioOptions
, All the audio options. These can be easily overwritten or extended using addAudioOptions(), or replaceAudioOptions( ). By default, they're populated using the ./audios.json file
visualCaptcha/Captcha methods
You'll find more documentation on the code itself, but here's the simple list for reference.
__construct( $session, $assetsPath = null, $defaultImages = null, $defaultAudios = null )
— Initialize the visualCaptcha object.generate( $numberOfOptions = 5 )
— Will generate a new valid option, within a$numberOfOptions
.streamAudio( $headers, $fileType )
— Stream audio file.streamImage( $headers, $index, $isRetina )
— Stream image file given an index in the session visualCaptcha images array.getFrontendData()
— Get data to be used by the frontend.getValidImageOption()
— Get the current validImageOption.getValidAudioOption()
— Get the current validAudioOption.validateImage( $sentOption )
— Validate the sent image value with the validImageOption.validateAudio( $sentOption )
— Validate the sent audio value with the validAudioOption.getImageOptions()
— Return generated image options.getImageOptionAtIndex( $index )
— Return generated image option at index.getAudioOption()
— Alias for getValidAudioOption.getAllImageOptions()
— Return all the image options.getAllAudioOptions()
— Return all the audio options.
License
View the LICENSE file.