jQuery integration layer for yii2 asset bundles, client validation scripts, and widget client scripts.

Maintainers

Package info

github.com/yii2-framework/jquery

Language:JavaScript

pkg:composer/yii2-framework/jquery

Statistics

Installs: 958

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

dev-main / 0.1.x-dev 2026-04-01 12:36 UTC

This package is auto-updated.

Last update: 2026-04-01 12:36:59 UTC


README

Yii Framework

jQuery


PHPUnit Mutation Testing PHPStan

Optional jQuery integration layer for yii2-framework/yii2
Asset bundles, client-side validation scripts, and widget client scripts — all jQuery-backed

Overview

This package restores the jQuery-powered client-side layer that was extracted from yii2-framework/yii2.

Install it when your application still relies on classic Yii2 page flows such as:

  • yii.js data-method, confirmation, and CSRF helpers;
  • ActiveForm client-side and Ajax validation;
  • GridView filtering and checkbox selection scripts;
  • Captcha, MaskedInput, and Pjax jQuery integrations.

The package is intentionally optional. Applications that no longer need jQuery should avoid installing it and should provide an alternative client-side integration strategy instead.

Features

Feature Overview

Quick start

Installation

composer require yii2-framework/jquery:^0.1@dev

Asset installation

This package uses php-forge/foxy to install npm dependencies such as jQuery, Inputmask, and jquery-pjax during composer install or composer update.

The @npm alias must point to your project's node_modules directory:

// config/web.php
return [
    'aliases' => [
        '@npm' => dirname(__DIR__) . '/node_modules',
    ],
    // ...
];

If npm packages are not installed automatically, verify that:

  1. php-forge/foxy is allowed in your composer.json:
{
    "config": {
        "allow-plugins": {
            "php-forge/foxy": true
        }
    }
}
  1. Run composer update to trigger the asset merge.

Configuration

Register the bootstrap class in your application configuration:

// config/web.php
return [
    'bootstrap' => [\yii\jquery\Bootstrap::class],
    // ...
];

Bootstrap configures the DI container with jQuery-based $clientScript defaults for validators and widgets that support strategy-based client integrations.

Overriding a single validator

public function rules(): array
{
    return [
        [
            'email',
            'required',
            'clientScript' => ['class' => MyCustomRequiredClientScript::class],
        ],
    ];
}

When to use this package

Use yii2-framework/jquery when your application still renders classic Yii2 views and depends on jQuery-backed widget behavior or client validation.

Do not use this package as the foundation for a new frontend modernization effort. When migrating away from jQuery, the recommended direction is to keep this package only on legacy pages and introduce a separate frontend integration layer for new pages.

Documentation

Package information

PHP Latest Stable Version Total Downloads

Quality code

Codecov PHPStan Level Max Super-Linter StyleCI

Our social networks

Follow on X

License

License