hcaptcha PHP implementation

v1.1.0 2020-08-04 00:19 UTC

This package is auto-updated.

Last update: 2024-06-04 08:12:22 UTC


Build Status Maintainability Test Coverage

hcaptcha header

⚠️ I'm not affiliated in any way with hCaptcha ⚠️

Easy integration of hCaptcha, a service that

  • Keeps bots out;
  • Earns you money;
  • Is privacy conscious.

Quick start

  1. Sign up at hCaptcha.

  2. Fetch your public key and site key from the settings tab.

  3. Get this package composer require neoan3-apps/hcaptcha

  4. Set up your front end as:

        <script src="" async defer></script>
    <form action="endpoint.php" method="post">
        <div class="h-captcha" data-sitekey="your-sitekey"></div>
        <input type="submit" value="send">
  1. Now in your PHP back end:
       'siteKey' => 'your-sitekey',
       'secret' => 'your-secret',
       'apiKey' => 'your-api-key'
   if(isset($_POST['my-form']) && \Neoan3\Apps\Hcapture::isHuman())
       ... do stuff

hCapture neoan3 API

Here are some methods for you to use and setup hCaptcha in your project.

Environment setup

For your global environment setup, please use the following methods:

// Set your own secret key
setSecret(string $value);

// API Key of hCaptcha linked to your account
setApiKey(string $value);

// Secret site key linked to your site
// See:
setSiteKey(string $value);

// With an array of environment variables provided, set all of them
// This is a 'shortcut' for all three previous methods
setEnvironment(array $environmentVariables);

hCaptcha utils

To retrieve hCaptcha information, here are the methods you will need:

// Check if the hCaptcha verification was successful

// Retrieve all statitics of the site corresponding to the 
// provided variables (an error value is returned in case of
// invalid credentials)

Advanced setup

You can have more details about advanced setup on the configuration page of the documentation.