Updating Varbase to work with Composer 2.0
Recommended to read:
As for Varbase 8.8.8 and Varbase 9.0.0-rc1, Varbase works with both Composer 1.0 and Composer 2.0
Recommended to build all new Varbase Projects with Composer 2.0
If the site was built recently with the listed latest releases Varbase 8.8.8 or Varbase 9.0.0-rc1, but the project was built using the Composer 1.0 version. The site is ready to start using Composer 2.0
Only update the Composer from 1.0 to 2.0
Do acomposer updateto update the autoloaders, namespaces map, and classes map.
If the site was built with Varbase 8.8.7 and older, Follow the following steps:
Step #1: Update composer to latest composer 1.0 by
1
composer self-update --1
Copied!
Step #2: Update Varbase projectcomposer.josn file
Change the following:
1
"composer/installers": "~1.0",
2
"oomphinc/composer-installers-extender": "~1.0",
3
"cweagans/composer-patches": "~1.0",
4
"drupal/drupal-library-installer-plugin": "^0.3",
Copied!
To:
1
"composer/installers": "~1.0 || ~2.0",
2
"oomphinc/composer-installers-extender": "~1.0 || ~2.0",
3
"cweagans/composer-patches": "~1.0",
Copied!
Remove drupal/drupal-library-installer-plugin
Step #3: Update Varbase to 8.8.8 or 9.0.0-rc1 with Composer 1.0
1
cd /PATH_TO_THE_PROJECT
2
composer update -vvv
Copied!
Repeat this composer update 2 or 3 times to make sure that their are no updates
Step #4: Update composer to latest composer 2.0 by
1
composer self-update --2
Copied!
Step #5: Rebuild the autoloader for map of classes and namespaces
1
cd /PATH_TO_THE_PROJECT
2
rm -rf composer.lock bin/ vendor/ docroot/modules/contrib/ docroot/themes/contrib/ docroot/profiles/varbase/ docroot/libraries/
3
composer install -vvv
4
cd docroot/
5
drush cr
Copied!
At this point the autoload and real autoload files + mapping should be changed.
When having any custom composer plugins or still having issues. Or if modules are using the old way of autoloading
Custom Composer plugins must have "composer-plugin-api": "^1.1 || ^2"
Make sure that the root composer.json file do not have invalid PSR-0 / PSR-4 . And the class configurations will not autoload anymore in optimized-autoloader mode, as per the warnings introduced in 1.10
Known issues:
After Composer 2.2.1 was released 2021-12-22
  • Fixed plugin autoloading including files autoload rules from the root package (#10382)
Update the root composer.json file with the following composer config
1
"config": {
2
"bin-dir": "bin/",
3
"secure-http": false,
4
"optimize-autoloader": true,
5
"preferred-install": {
6
"drupal/core": "dist"
7
},
8
"allow-plugins": {
9
"composer/installers": true,
10
"cweagans/composer-patches": true,
11
"oomphinc/composer-installers-extender": true,
12
"drupal/core-composer-scaffold": true,
13
"drupal/core-project-message": true,
14
"vardot/varbase-updater": true
15
}
16
},
Copied!
Rebuild the autoloader for map of classes and namespaces
1
cd /PATH_TO_YOUR_PROJECT
2
rm -rf composer.lock bin/ vendor/ docroot/modules/contrib/ docroot/themes/contrib/ docroot/profiles/varbase/ docroot/libraries/
3
composer install -vvv
4
cd docroot/
5
drush cr
Copied!
Last modified 28d ago
Export as PDF
Copy link