Download the PHP package wymarzonylogin/piksel-kapcio without Composer

On this page you can find all versions of the php package wymarzonylogin/piksel-kapcio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package piksel-kapcio

Piksel Kapcio

This is a PHP captcha-like library.

piksel-kapcio-title

Advertisment

Are you tired of users complaining that this obscure captcha you use on your website is sooo annonying and hard to solve? Are you bored with all the bots being defeated by the captcha you use? Well, we have good news for you! Piksel Kapcio is now available! It's a captcha library, but not really! It's really easy to read, both for humans and bots!

By the way, ever wondered how captcha would look like on C64?

What is it?

It's bascially a simple captcha package to use within your PHP projects.

Disclaimer

Use at your own risk! This was never meant to be a hard to solve captcha. I never tried it against bots, so I can only assume it's not really good. This was created more as an easy to configure, easy to use, easy to solve thing, with specific esthetics applied, that would throttle human users a bit. This works great in my use case, but it doesn't have to for you! Always pick right tool for the job.

Installation

Easy peasy, just use composer:

Basic usage

Typical flow for captchas is as follows:

In other words, you need to take 3 steps to use it:

  1. Create endpoint serving images to user (and also storing generated code text in session)
  2. Modify your form to show image (call endpoint from step 1) and add field for user's solution for captcha (also show there error, if solution is wrong).
  3. Verify submitted user's captcha solution.

1. Endpoint serving images

Here is the example of basic endpoint:

Let's assume this endpoint is called for /captcha-image relative URL in your app.

2. Your form

If you notice that image becomes cached (after first try, same image is served to given user all the time) try appending query string containing some unique parameter to called image serving endopoint's URL.

With default configuration, served image would look something like this:

serve-image-default

3. Verify submitted data

Below there's an example code for handling form submission. Do not modify code in this package's ExampleController - copy the code to your namespace instead and then work on it.

Luckily you dont need to configure anything. You can see basic usage in \WymarzonyLogin\PikselKapcio\Controller\ExampleController class. You can actually use this controller's serveImage method for serving images, if you are fine with default configuration.

Flow

You basically have two touchpoints using Piksel Kapcio.

  1. Generate new code, save it in user session and serve the image.
  2. Verify if code provided by user matches the code stored in session.

The first step you achieve by generating new code (generate text, store it in session and generate corresponding image data):

$newCode object over here is instance of WymarzonyLogin\PikselKapcio\Code. You can call 2 methods on instance of Code object:

To serve the image, simply do this afterwards:

For code verification, you simply call validateCode with user provided captcha solution on CodeManager:

validateCode function returns true in case if user provided code is correct or false otherwise.

Configuration

There are 2 things that can be configured separately: code generation and image generation.

Code generation

You can configure text generation of the code and set your custom session key for captcha code. You can do that by providing valid CodeManagerConfig object as a first parameter to CodeManager constructor:

This parameter can be also null and you don't need to pass it at all.

Custom session keys

There is a small chance that the default session key used by the package ( _wl_kapcio) will collide with session keys used by other packages. In that case you will want to use a custom session key for piksel-kapcio. Other, more probable case, is that you have more than one form that you want to protect with captcha. In the latter case, each form should receive a code generated with separate session key, and should be validated with this session key used. Session key is set via constructor of CodeManagerConfig object:

Please keep in mind that instance of CodeManager used both for generation and validation of corresponding code needs to be instantiated with exactly same session key set in passed CodeManagerConfig object.

Text generation mode

There are two modes for generating text:

By default, random text mode is used. You can set the mode like that:

Random text length

If random text mode is used, the length of the generated code can be defined:

Default value is 4. Custom value needs to be in range [1,36]

Custom words list

There is default list of words already provided, but I'm pretty sure you will want to overwrite it. Simply pass array of words like that:

Respected characters

For custom words list, for each word please do not use characters other than:

Other characters would be rendered as space (empty block)

Case sensitivity

Piksel Kapcio is case insensitive. Your words can contain uppercase and/or lowercase latin letters, users can provide their captcha solutions in any case as well. Code will be conisdered valid, if letter match, whatever the case (e.g. if you provide custom word 'AmsterDam', and user responds with 'amsterDAM', solution will be considered as valid).

Image generation

You can configure image generation of the code (the visual aspects of image representing code) by providing valid ImageGeneratorConfig object as a second parameter to CodeManager constructor:

This parameter can be also null and you don't need to pass it at all.

Scale

All the code images are build from characters build of "pixels". By defining scale, you can set size of "pixels" in real pixels. The bigger the scale, the bigger the image and each character presented on it. Default value is 5, which means that your image would be 35 pixels tall (5 x 5 for characted height + 2 x 5 for small padding on the bottom and top). Set your custom scale:

The above code would make each character on the generated code image be 49 x 49 real pixels.

Color pairs

Color pair is array of 2 hex html color codes (background and foreground color). You can define multiple color pairs. Each character on generated image will use just one color pair (picked randomly or in sequence). There is a set of few color pairs defined by default, but you are free to customize it.

This package was developed in Berlin, so lets set our color pairs to reflect german flag:

First pair has black for background and grey for foreground. Second - red and grey, third - yellow and grey. Result could look like this:

random-bg

You can make it the other way, lets have grey backgrounds and colorful foregrounds:

Result could be like this:

random-fg

You can of course set different foreground and background colors for each pair at the same time, just like in default color pairs set.

Color pairs rotation

By default, color pair for each character is picked randomly from defined set of color pairs. If you wish, you can change it to sequence. Let's get back to german flag background colors. Lets define these color pairs again and set sequence rotation for color pairs.

The result would be now less chaotic than previously:

sequence-bg

Full configuration example

Please note that ImageGeneratorConfig is not passed in form submission validation endpoint - it is not needed here, as it only affects generation of the image. What is more important - in both endpoints, CodeManagerConfig objects instantiated with same session key were provided to CodeManager constructor.


All versions of piksel-kapcio with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wymarzonylogin/piksel-kapcio contains the following files

Loading the files please wait ....