yii2-framework / jquery
jQuery integration layer for yii2 asset bundles, client validation scripts, and widget client scripts.
Package info
github.com/yii2-framework/jquery
Language:JavaScript
pkg:composer/yii2-framework/jquery
Requires
- php: >=8.2
- yii2-framework/yii2: ^0.1@dev
Requires (Dev)
- infection/infection: ^0.27|^0.32
- maglnet/composer-require-checker: ^4.1
- php-forge/coding-standard: ^0.1
- php-forge/foxy: ^0.2
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-strict-rules: ^2.0.3
- phpunit/phpunit: ^10.5
- yii2-extensions/phpstan: ^0.4
This package is auto-updated.
Last update: 2026-04-04 15:28:57 UTC
README
jQuery
Optional jQuery integration layer for 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.
The package supports jQuery 3.7.1 and jQuery 4.0.0. The bundled npm dependency defaults to jQuery 3.7.1 so
legacy Yii2 applications remain safe by default. Applications that want jQuery 4.0.0 must pin it explicitly in
their project-level package.json.
Install it when your application still relies on classic Yii2 page flows such as:
yii.jsdata-method, confirmation, and CSRF helpers;ActiveFormclient-side and Ajax validation;GridViewfiltering and checkbox selection scripts;Captcha,MaskedInput, andPjaxjQuery 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
Quick start
Installation
composer require yii2-framework/jquery:^0.1
Asset installation
This package uses php-forge/foxy to install npm dependencies such as jQuery,
Inputmask, and Punycode 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:
php-forge/foxyis allowed in yourcomposer.json:
{
"config": {
"allow-plugins": {
"php-forge/foxy": true
}
}
}
- Run
composer updateto trigger the asset merge.
jQuery version selection
By default, this package installs jQuery 3.7.1.
If your application is ready to run on jQuery 4.0.0, pin it explicitly in the project-level package.json and run
composer update again so the merged npm manifest is refreshed:
{
"dependencies": {
"jquery": "^4.0.0"
}
}
Use the full jQuery build. This package depends on Ajax and Deferred APIs and is not compatible with the slim build.
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
- ๐ Installation Guide
- โ๏ธ Configuration Reference
- ๐ก Usage Examples
- ๐งช Testing Guide