Download the PHP package matt/sycaptcha without Composer

On this page you can find all versions of the php package matt/sycaptcha. 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 sycaptcha

SyCaptchaBundle

SyCaptchaBundle is a form protection bundle made for Symfony, including a set of CAPTCHA challenges that should stop any malicious requests from submitting your forms.

Supported CAPTCHAs

There are three types of supported CAPTCHAs as of now

  1. reCaptcha V2 - By Google
  2. reCaptcha V3 - By Google
  3. hCaptcha - By Intuition Machines

Invisible reCaptcha V2 isn't supported, due to the fact that it's 'lower' end version of reCaptcha V3

Installation

With composer require

composer require matt/sycaptcha

Configuration without symfony/flex

You can configure all the needed files manually when not having an option to install/upgrade to symfony/flex

1. Register the bundle

Register bundle into config/bundles.php Symfony 4/5

return [
    Matt\SyCaptchaBundle\SyCaptchaBundle::class => ['all' => true],
];

Register bundle into app/AppKernel.php Symfony 3 and below

public function registerBundles()
{
    return [
        new Matt\SyCaptchaBundle\SyCaptchaBundle(),
    ];
}

2. Add configuration files

config/packages/sy_captcha.yaml (or app/config/config.yml if using Symfony 3 or below)

sy_captcha:  
  recaptcha_v2:  
    site_key: 'site_key'  
    secret_key: 'secret_key'  

Usage

Let's finally get to the part about how you can integrate those CAPTCHAS into your forms.

1. Create form and add the CAPTCHA protection

You can add all three CAPTCHAS into the form at the same time (yes, it's overkill), however, they all need to be configured properly

<?php  

use Matt\SyCaptchaBundle\Form\Type\SyCaptchaHCaptchaType;  

class FormType extends AbstractType  
{  
  public function buildForm(FormBuilderInterface $builder, array $options): void  
  {  
      $builder->add('captcha', SyCaptchaHCaptchaType::class);
  }  
}

2. Configure the CAPTCHA if needed

There are series of parameters that can be used to configure the CAPTCHA and it's scripts. Most of them are being set via configuration file (more in whole configuration section) but few of them are being declared via form options. Those are

  1. action_name - Sets the action name (reCaptcha V3 Only)
  2. theme - Sets the CAPTCHA theme to either light / dark (reCaptcha V2 and hCaptcha Only)
  3. script_nonce_csp - Sets the nonce of all scripts injected via CAPTCHA widget

Full config explanation

The whole config looks like this now

sy_captcha:  
  enabled: true  
  recaptcha_v2:  
    site_key: null  
    secret_key: null  
    api_host: 'www.google.com'  
  recaptcha_v3:  
    site_key: null  
    secret_key: null  
    api_host: 'www.google.com'  
    score_threshold: 0.5  
  hcaptcha:  
    site_key: null  
    secret_key: null  
    api_host: 'js.hcaptcha.com'  
    invisible: false

As you can see there are few configurable options, and their default values. Let's break the script a little, please note that some options are only available for hCaptcha, some for reCaptcha only and so forth.

Including .ENV values into config

This is just a little tip, but you can include .ENV values in your Symfony config. All you need to do is to reference it via %env(VARIABLE)% tag in your config.

sy_captcha:
    enabled: '%env(SYCAPTCHA_ENABLED)%'

TODO

A little list of plans for the future


All versions of sycaptcha with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
symfony/framework-bundle Version ^5.2
symfony/twig-bundle Version ^5.3
google/recaptcha Version ^1.2
symfony/form Version ^5.3
twig/twig Version ^3.3
symfony/yaml Version ^5.3
symfony/validator Version ^5.3
ext-curl Version *
ext-json Version *
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 matt/sycaptcha contains the following files

Loading the files please wait ....