我刚刚在 Mac 操作系统上创建了新的 Yii 2 应用程序。我使用的 PHP 版本是
7.3
版本。 Composer 安装工作正常,但当我尝试使用命令 php yii serve
启动应用程序时,出现以下错误。
Exception 'yii\base\InvalidConfigException' with message 'Failed to instantiate component or class "yii\gii\Module".'
in /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/di/Container.php:449
Stack trace:
#0 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/di/Container.php(374): yii\di\Container->getDependencies('yii\\gii\\Module')
#1 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/di/Container.php(159): yii\di\Container->build('yii\\gii\\Module', Array, Array)
#2 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('yii\\gii\\Module', Array, Array)
#3 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/base/Module.php(427): yii\BaseYii::createObject(Array, Array)
#4 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/base/Application.php(315): yii\base\Module->getModule('gii')
#5 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/base/Application.php(273): yii\base\Application->bootstrap()
#6 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/console/Application.php(124): yii\base\Application->init()
#7 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\console\Application->init()
#8 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#9 /Users/krishnadas/Desktop/thejas/lms/vendor/yiisoft/yii2/console/Application.php(89): yii\base\Application->__construct(Array)
#10 /Users/krishnadas/Desktop/thejas/lms/yii(19): yii\console\Application->__construct(Array)
#11 {main}
当我运行作曲家更新时,我收到更多这样的错误
ailed to extract yiisoft/yii2-bootstrap: (9) unzip -qq '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-26e4a5cb7b14ec2c9244cc7f29b77c9d' -d '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/63a3aea5'
unzip: cannot find or open /Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-26e4a5cb7b14ec2c9244cc7f29b77c9d.
This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
Failed to extract yiisoft/yii2-debug: (9) unzip -qq '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-ee4e9bc3f65bc1e6d3bb29c47448147f' -d '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/c3a14115'
unzip: cannot find or open /Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-ee4e9bc3f65bc1e6d3bb29c47448147f.
This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
Failed to extract yiisoft/yii2-faker: (9) unzip -qq '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-adfed1b28e8eb6386664db1dc98849ab' -d '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/d8990f9a'
unzip: cannot find or open /Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-adfed1b28e8eb6386664db1dc98849ab.
This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
Failed to extract yiisoft/yii2-gii: (9) unzip -qq '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-a51d0a4cc1fef91725fe727eb3a41a43' -d '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/eaed0437'
unzip: cannot find or open /Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-a51d0a4cc1fef91725fe727eb3a41a43.
This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix
Failed to extract yiisoft/yii2-swiftmailer: (9) unzip -qq '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-d3e0c5f68aded7a5357259ffde56f5ea' -d '/Users/krishnadas/Desktop/thejas/basic/vendor/composer/3514a4ce'
unzip: cannot find or open /Users/krishnadas/Desktop/thejas/basic/vendor/composer/tmp-d3e0c5f68aded7a5357259ffde56f5ea.
This most likely is due to a custom installer plugin not handling the returned Promise from the downloader
See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix`
当我将composer降级到最新的稳定版本时,它终于起作用了
1.10.7
。版本 2
的某些安装项目存在问题,例如 gii
。
我更新了 Mac 上的 Composer 并解决了问题。 安装后只需
composer update