Missing composer "allow-plugins" config

Before July 1st 2022, if the allow-plugins config block wasn't specified in your project's composer.json file, then Composer permissively allowed any package to act as a Composer plugin.

However, nowadays if the block isn't specified then Craft CMS will start exhibiting some unusual behaviour, primarily:

  • Craft plugins suddenly disappear.
  • Plugin functions are no longer available and cause PHP errors.

This is because Craft relies on the yiisoft/yii2-composer composer package to load your project's Craft CMS plugins. If it isn't permitted to act as a Composer plugin via the allow-plugins block, then it's not able to scan for your Craft CMS plugins installed via Composer, so they appear to vanish.

For recently created Craft CMS projects, this doesn't tend to be an issue because newer versions of Craft's project generator will initialise a composer.json file with the correct allow-plugins configuration. It nearly always occurs in older projects that haven't be modified in a while, or were upgraded but the composer.json file wasn't correctly updated.

How to fix #

If your Servd project doesn't have an allow-plugins block in your composer.json, perform the following steps:

  1. Open your composer.json file in your local development environment.

  2. Add the allow-plugins block to your project's composer.json file. It should look like something like this.

    Please note:

    • The block should be nested within the config block, it shouldn't be at the top-level of the JSON object.
    • If the config block is already present, merge the above allow-plugins block inside it instead of replacing.
  3. Commit the change and push it to your project's git repository.

  4. Sync your project to deploy the changes.