nystudio107/craft-autocomplete

Missing required parameter "id" when instantiating

Closed this issue · 5 comments

I was trying to install craft-autocomplete in PhpStorm and ran into the following error:

Missing required parameter "id" when instantiating "nystudio107\autocomplete\Autocomplete".

Additional context

Craft Solo 3.5.19.1
PHP 7.4.21

"require": {
  "craftcms/cms": "^3.0.1",
  "vlucas/phpdotenv": "^2.4.0",
  "focuslabllc/craft-cheat-sheet": "^2.0.3"
},

Output

bash-3.2$ composer require nystudio107/craft-autocomplete --dev
Using version ^1.10 for nystudio107/craft-autocomplete
./composer.json has been updated
Running composer update nystudio107/craft-autocomplete
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking nystudio107/craft-autocomplete (1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing nystudio107/craft-autocomplete (1.10.0): Extracting archive
Generating optimized autoload files

Error

2022-03-02 14:02:24 [-][-][-][error][yii\base\InvalidConfigException] yii\base\InvalidConfigException: Missing required parameter "id" when instantiating "nystudio107\autocomplete\Autocomplete". in /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/di/Container.php:498
Stack trace:
#0 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/di/Container.php(393): yii\di\Container->resolveDependencies(Array, Object(ReflectionClass))
#1 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/di/Container.php(165): yii\di\Container->build('nystudio107\\aut...', Array, Array)
#2 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/BaseYii.php(345): yii\di\Container->get('nystudio107\\aut...', Array)
#3 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/base/Application.php(294): yii\BaseYii::createObject('nystudio107\\aut...')
#4 /Users/hartbr/websites/brianhartdesign-craft3/vendor/craftcms/cms/src/console/Application.php(61): yii\base\Application->bootstrap()
#5 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/base/Application.php(273): craft\console\Application->bootstrap()
#6 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/console/Application.php(124): yii\base\Application->init()
#7 /Users/hartbr/websites/brianhartdesign-craft3/vendor/craftcms/cms/src/console/Application.php(47): yii\console\Application->init()
#8 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#9 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#10 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#11 [internal function]: yii\console\Application->__construct(Array)
#12 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/di/Container.php(406): ReflectionClass->newInstanceArgs(Array)
#13 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/di/Container.php(165): yii\di\Container->build('craft\\console\\A...', Array, Array)
#14 /Users/hartbr/websites/brianhartdesign-craft3/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\console\\A...', Array, Array)
#15 /Users/hartbr/websites/brianhartdesign-craft3/vendor/craftcms/cms/bootstrap/bootstrap.php(246): yii\BaseYii::createObject(Array)
#16 /Users/hartbr/websites/brianhartdesign-craft3/vendor/craftcms/cms/bootstrap/console.php(51): require('/Users/hartbr/w...')
#17 /Users/hartbr/websites/brianhartdesign-craft3/craft(21): require('/Users/hartbr/w...')
#18 {main}

Any chance you can test this on a more recent version of Craft, to help eliminate the possibility that the issue is with an old version of Yii?

Updated to the latest version of Craft - that fixed it. Thanks for your help gents.

huh. Might have been a bug in the version of Yii2 that some older version of Craft required, I suppose.

Should we try to retroactively fix this @bencroker ? Or just tell people to update?

Sounds like a Yii bug that was since resolved, so I'd say we leave it as is.

Addressed in: d5dfa7e

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-autocomplete": "dev-develop as 1.10.1”,

Then do a composer clear-cache && composer update