PHPackages                             nsu-soft/yii-cap-captcha-widget - 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. [Security](/categories/security)
4. /
5. nsu-soft/yii-cap-captcha-widget

ActiveLibrary[Security](/categories/security)

nsu-soft/yii-cap-captcha-widget
===============================

Widget for Yii views to check captcha by Cap Captcha service

1.0.2(2mo ago)07BSD-3-ClausePHPPHP &gt;=8.3

Since Mar 19Pushed 2mo agoCompare

[ Source](https://github.com/nsu-soft/yii-cap-captcha-widget)[ Packagist](https://packagist.org/packages/nsu-soft/yii-cap-captcha-widget)[ RSS](/packages/nsu-soft-yii-cap-captcha-widget/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (14)Versions (9)Used By (0)

yii-cap-captcha-widget
======================

[](#yii-cap-captcha-widget)

[На русском](docs/ru-RU/README.md)

[![License](https://camo.githubusercontent.com/6cb285b57819f8de0acfb34923298f4f569f962544e8fe35331da2d163f4e485/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/82f2ea35cf5859a37ddb09e749933f856efbb2ca9be0231de6ad6e0abbfcc8c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e332d3838393242462e7376673f6c6f676f3d706870)](https://php.net)[![Yii Version](https://camo.githubusercontent.com/bcc4a3ac99a3802e6dd12cdbe5a679645ad218f297eca34fb221736851ceae6c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7969692d7e322e302e35302d4534374234342e7376673f6c6f676f3d796969)](https://www.yiiframework.com)[![Status](https://camo.githubusercontent.com/395cf373baf3b12693c06c8f312d0c0e6914dbc7f84c01c6d1e0687694f73a28/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461626c652d312e302e322d626c75652e737667)](https://packagist.org/packages/nsu-soft/yii-cap-captcha-widget)

---

📑 Table of Contents
-------------------

[](#-table-of-contents)

- [Overview](#-overview)
- [Features](#-features)
- [Requirements](#-requirements)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Usage](#-usage)
- [Quick Start with Docker](#-quick-start-with-docker)
- [Widget Properties Reference](#-widget-properties-reference)
- [Testing](#-testing)
- [Project Structure](#-project-structure)
- [Integration with yii-cap-captcha](#-integration-with-yii-cap-captcha)
- [Security](#-security)
- [Contributing](#-contributing)
- [License](#-license)

---

📋 Overview
----------

[](#-overview)

**yii-cap-captcha-widget** is a Yii2 view widget that provides seamless integration of the **[Cap Captcha](https://capjs.js.org)** client-side widget into your Yii2 application forms. It renders the CAPTCHA challenge interface and handles token generation using the official `@cap.js/widget` NPM package.

This widget works in conjunction with the **[yii-cap-captcha](https://github.com/nsu-soft/yii-cap-captcha)** server-side component to provide complete bot protection: the widget handles client-side challenge display and token generation, while the companion package validates tokens on the server. Or you can use your own solution to validate tokens on the server. It's up to you.

---

✨ Features
----------

[](#-features)

- 🧩 **Native Yii2 Widget**: Drop-in component following Yii2 widget conventions (`CapWidget::widget()`).
- 🔐 **Cap Captcha Integration**: Renders the official Cap widget with full configuration support.
- ⚙️ **Flexible Configuration**: Customize endpoint, callback handlers, and widget options via PHP properties.
- 🎨 **Asset Management**: Automatic registration of required JS assets via Yii2 AssetBundle.
- 🔄 **Event-Driven**: Support for `onSolve` JavaScript callback to handle token submission.
- 🐳 **Docker-Ready**: Pre-configured environment for local development and testing.
- 🧪 **Tested**: Includes Codeception test suite for functional and unit testing.

---

🔧 Requirements
--------------

[](#-requirements)

ComponentVersionDescription**PHP**`>= 8.3`Required PHP version**Yii Framework**`~2.0.50`Yii2 web application framework### Optional (Recommended)

[](#optional-recommended)

ComponentVersionDescription**nsu-soft/yii-cap-captcha**`^3.0`Server-side component for token validation---

📦 Installation
--------------

[](#-installation)

If you don't have Composer, you may install it by [following instruction](https://getcomposer.org/doc/00-intro.md).

Install the package via Composer:

```
composer require nsu-soft/yii-cap-captcha-widget
```

Install the server-side validation package, if you don't have your own solution. See the [following instruction](https://github.com/nsu-soft/yii-cap-captcha?tab=readme-ov-file#-installation).

---

⚙️ Configuration
----------------

[](#️-configuration)

If you use `nsu-soft/yii-cap-captcha` package, configure it by [following instruction](https://github.com/nsu-soft/yii-cap-captcha?tab=readme-ov-file#%EF%B8%8F-configuration)

---

💻 Usage
-------

[](#-usage)

### Basic Widget Rendering

[](#basic-widget-rendering)

Render the widget directly in your Yii2 view file:

```
