Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].
1、Lighthouse 大量使用 SDL 并利用模式指令。为了改善您的编辑体验,您可以使用 artisan 命令生成定义文件。报错:Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].如图1
PS E:\wwwroot\object> php artisan lighthouse:ide-helper
Wrote schema directive definitions to E:\wwwroot\object/schema-directives.graphql.
Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].
at E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php:978
974| } else {
975| $message = "Target [$concrete] is not instantiable.";
976| }
977|
> 978| throw new BindingResolutionException($message);
979| }
980|
981| /**
982| * Throw an exception for an unresolvable primitive.
Exception trace:
2、执行命令:php artisan module:list,显示所有模块的列表。确认模块 ThemeStore 已禁用。如图2
PS E:\wwwroot\object> php artisan module:list +-----------------------+----------+-------+---------------------------------------------------------+ | Name | Status | Order | Path | +-----------------------+----------+-------+---------------------------------------------------------+ | ThemeStore | Disabled | 0 | E:\wwwroot\object\Modules/ThemeStore |
3、启用模块 ThemeStore 后,仍然报同样的错误
PS E:\wwwroot\object> php artisan module:enable ThemeStore
Module [ThemeStore] enabled successful.
PS E:\wwwroot\object> php artisan lighthouse:ide-helper
Wrote schema directive definitions to E:\wwwroot\object/schema-directives.graphql.
Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].
at E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php:978
974| } else {
975| $message = "Target [$concrete] is not instantiable.";
976| }
977|
> 978| throw new BindingResolutionException($message);
979| }
980|
981| /**
982| * Throw an exception for an unresolvable primitive.
Exception trace:
4、最后发现原因在于 config/app.php 的 providers 中 Modules\ThemeStore\Providers\ThemeStoreServiceProvider::class 已经被注释所导致。缺少服务提供者的类。取消注释,不再报错。
PS E:\wwwroot\object> php artisan lighthouse:ide-helper Wrote schema directive definitions to E:\wwwroot\object/schema-directives.graphql. Wrote definitions for programmatically registered types to E:\wwwroot\object/programmatic-types.graphql. Wrote PHP definitions to E:\wwwroot\object/_lighthouse_ide_helper.php. It is recommended to add them to your .gitignore file.
![Lighthouse 大量使用 SDL 并利用模式指令。为了改善您的编辑体验,您可以使用 artisan 命令生成定义文件。报错:Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].](https://www.shuijingwanwq.com/wp-content/uploads/2022/05/1-6.png)

近期评论