I have a project which is working off of yii2's advanced template. When I checked the version of jquery in vendor/bower/jquery/dist/jquery.js the current version is 2.2.4. I want to update this version to version 3.2.1 but doing a composer update doesn't seem to update my bower assets. I tried setting composer global require "fxp/composer-asset-plugin:>=1.3.1"
and then ran composer update
again but no luck. The jquery version is still 2.2.4.
Is there something I'm missing?
You don't actually need to use composer for switching to newer jQuery version. By configuring yii\web\JqueryAsset
you can override loaded jQuery library at your wish, e.g.
in /config/main.php:
...
'components' => [
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'js' => [YII_DEBUG ? 'https://code.jquery.com/jquery-3.2.1.js' : 'https://code.jquery.com/jquery-3.2.1.min.js'],
'jsOptions' => ['type' => 'text/javascript'],
],
],
],
],
The problem is that the Yii2 framework has a dependency defined in its own composer file /vendor/yiisoft/yii2/composer.json
file that looks like this:
"bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable"
Basically that restricts the jQuery version for your application.
Unfortunately, I can't see how to get around this issue right now. But there is already an issue raised on GitHub for it and the Milestone is set to 2.0.13 so hopefully it'll be updated then: https://github.com/yiisoft/yii2/issues/14338
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With