php 不存在请求的页面\Contracts\Container\BindingResolutionException -目标类[CommandMakeCommand]

sq1bmfud  于 2023-02-28  发布在  PHP
关注(0)|答案(9)|浏览(205)

使用Laravel 8.75并尝试在composer.json中升级到php 8.1到“php”:“^8.1”并收到Illuminate\Contracts\Container\BindingResolutionException错误-目标类[CommandMakeCommand]不存在。

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. 
Use symfony/mailer instead.
Generating optimized autoload files
 
Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover --ansi

Illuminate\Contracts\Container\BindingResolutionException

Target class [CommandMakeCommand] does not exist.

at

供应商/laravel/框架/src/照明/容器/容器。php:879

875▕
876▕         try {
877▕             $reflector = new ReflectionClass($concrete);
878▕         } catch (ReflectionException $e) {
879▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
880▕         }
881▕
882▕         // If the type is not instantiable, the developer is attempting to resolve
883▕         // an abstract type such as an Interface or Abstract Class and there is

  +13 vendor frames
 14  artisan:37
 Illuminate\Foundation\Console\Kernel::handle()
Script @php artisan package:discover --ansi handling the post-autoload- 
dump event returned with error code 1
rekjcdws

rekjcdws1#

我也有同样的问题,在我的情况下nwidart/laravel模块包升级到8.3版本,我降级到8.2版本和问题解决

qnyhuwrf

qnyhuwrf2#

参见此处:https://docs.laravelmodules.com/v9/introduction
如果您有一个现有的配置文件,并且收到一个错误:
Target class [CommandMakeCommand] does not exist
然后配置文件将需要更新,首先导入命令类:
use Nwidart\Modules\Commands;
接下来将命令数组替换为:

'commands' => [
    Commands\CommandMakeCommand::class,
    Commands\ComponentClassMakeCommand::class,
    Commands\ComponentViewMakeCommand::class,
    Commands\ControllerMakeCommand::class,
    Commands\DisableCommand::class,
    Commands\DumpCommand::class,
    Commands\EnableCommand::class,
    Commands\EventMakeCommand::class,
    Commands\JobMakeCommand::class,
    Commands\ListenerMakeCommand::class,
    Commands\MailMakeCommand::class,
    Commands\MiddlewareMakeCommand::class,
    Commands\NotificationMakeCommand::class,
    Commands\ProviderMakeCommand::class,
    Commands\RouteProviderMakeCommand::class,
    Commands\InstallCommand::class,
    Commands\ListCommand::class,
    Commands\ModuleDeleteCommand::class,
    Commands\ModuleMakeCommand::class,
    Commands\FactoryMakeCommand::class,
    Commands\PolicyMakeCommand::class,
    Commands\RequestMakeCommand::class,
    Commands\RuleMakeCommand::class,
    Commands\MigrateCommand::class,
    Commands\MigrateRefreshCommand::class,
    Commands\MigrateResetCommand::class,
    Commands\MigrateRollbackCommand::class,
    Commands\MigrateStatusCommand::class,
    Commands\MigrationMakeCommand::class,
    Commands\ModelMakeCommand::class,
    Commands\PublishCommand::class,
    Commands\PublishConfigurationCommand::class,
    Commands\PublishMigrationCommand::class,
    Commands\PublishTranslationCommand::class,
    Commands\SeedCommand::class,
    Commands\SeedMakeCommand::class,
    Commands\SetupCommand::class,
    Commands\UnUseCommand::class,
    Commands\UpdateCommand::class,
    Commands\UseCommand::class,
    Commands\ResourceMakeCommand::class,
    Commands\TestMakeCommand::class,
    Commands\LaravelModulesV6Migrator::class,
],
gtlvzcf8

gtlvzcf83#

只需添加以下行:

use Nwidart\Modules\Commands\CommandMakeCommand;

config/modules.php文件第一个中作为namespace
上述命名空间将仅解决commandMakeCommand问题,但如果您想设置所有命令命名空间,则需要在顶部添加命名空间。

namespace Nwidart\Modules\Commands;
ux6nzvsh

ux6nzvsh4#

希望这对您有所帮助(请先备份您的项目):
1.首先通过运行以下命令删除nwidart/laravel模块:composer remove nwidart/laravel-modules
1.然后删除config/modules.php
1.通过运行以下命令重新安装nwidart/laravel模块:composer require nwidart/laravel-modules
来源:Githubhot, the answer by mohamedsharaf

x6h2sr28

x6h2sr285#

如果有人仍在寻找答案,请按照以下步骤操作
如在此链接中提到的,请参见此处:https://docs.laravelmodules.com/v9/introduction
如果您有一个现有的配置文件,并且收到一个错误:

Target class [CommandMakeCommand] does not exist

然后,配置文件需要更新,首先导入commands类,然后在配置文件夹中更新modules.php文件,包括

use Nwidart\Modules\Commands;

然后将命令数组替换为:在每个值之前添加Commands\或简单复制并替换数组

'commands' => [
    Commands\CommandMakeCommand::class,
    Commands\ComponentClassMakeCommand::class,
    Commands\ComponentViewMakeCommand::class,
    Commands\ControllerMakeCommand::class,
    Commands\DisableCommand::class,
    Commands\DumpCommand::class,
    Commands\EnableCommand::class,
    Commands\EventMakeCommand::class,
    Commands\JobMakeCommand::class,
    Commands\ListenerMakeCommand::class,
    Commands\MailMakeCommand::class,
    Commands\MiddlewareMakeCommand::class,
    Commands\NotificationMakeCommand::class,
    Commands\ProviderMakeCommand::class,
    Commands\RouteProviderMakeCommand::class,
    Commands\InstallCommand::class,
    Commands\ListCommand::class,
    Commands\ModuleDeleteCommand::class,
    Commands\ModuleMakeCommand::class,
    Commands\FactoryMakeCommand::class,
    Commands\PolicyMakeCommand::class,
    Commands\RequestMakeCommand::class,
    Commands\RuleMakeCommand::class,
    Commands\MigrateCommand::class,
    Commands\MigrateRefreshCommand::class,
    Commands\MigrateResetCommand::class,
    Commands\MigrateRollbackCommand::class,
    Commands\MigrateStatusCommand::class,
    Commands\MigrationMakeCommand::class,
    Commands\ModelMakeCommand::class,
    Commands\PublishCommand::class,
    Commands\PublishConfigurationCommand::class,
    Commands\PublishMigrationCommand::class,
    Commands\PublishTranslationCommand::class,
    Commands\SeedCommand::class,
    Commands\SeedMakeCommand::class,
    Commands\SetupCommand::class,
    Commands\UnUseCommand::class,
    Commands\UpdateCommand::class,
    Commands\UseCommand::class,
    Commands\ResourceMakeCommand::class,
    Commands\TestMakeCommand::class,
    Commands\LaravelModulesV6Migrator::class,
],
5tmbdcev

5tmbdcev6#

您可以尝试降级composer.json文件中的nwidart/laravel-modules版本。只需将此行更改为下面的行。

"nwidart/laravel-modules": "8.2.*"

然后删除composer.lock文件,现在运行此命令。

composer install
lh80um4z

lh80um4z7#

在config/modules中,添加命令Nwidart\Modules\Commands名称完整路径
'命令' =〉[ Nwidart\模块\命令\命令生成命令::类...],

vfwfrxfs

vfwfrxfs8#

如果以前的答复不为您工作,如果在composer.json中更改版本以及删除composer.lock和供应商后仍然不工作,您可以像这样修复版本
“nwidart/laravel模块”:“第8.2条 *”
删除 composer .锁定和供应商并运行

composer install
qyzbxkaa

qyzbxkaa9#

这不是相关的路线或您的应用程序的任何其他部分,当您无法运行Composer更新或Artisan命令时,您在引导Laravel时遇到问题,在这种情况下:去你的配置文件夹打开模块文件并检查“命令”键我的问题通过这种方式修复!日安!

相关问题