没有不值得去解决的问题,也没有不值得去学习的技术!

Illuminate\Contracts\Container\BindingResolutionException: Target [Modules\ThemeStore\View\ViewStorageInterface] Is Not Instantiable While Building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver]

Lighthouse 大量使用 SDL 并利用模式指令。为了改善您的编辑体验,您可以使用 artisan 命令生成定义文件。报错:Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].

1. Lighthouse makes extensive use of SDL and schema directives. To improve your editing experience, you can use an artisan command to generate definition files. Error: Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver]. See Figure 1.

Lighthouse makes extensive use of SDL and schema directives. To improve your editing experience, you can use an artisan command to generate definition files. Error: Illuminate\Contracts\Container\BindingResolutionException : Target [Modules\ThemeStore\View\ViewStorageInterface] is not instantiable while building [Modules\ThemeStore\Resolver\OnlineStoreThemeResolver].
Figure 1
Plaintext

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. Run the command: php artisan module:list, which displays a list of all modules. Confirm that the ThemeStore module is disabled. See Figure 2.

Run the command: php artisan module:list, which displays a list of all modules. Confirm that the ThemeStore module is disabled
Figure 2
Plaintext

PS E:\wwwroot\object> php artisan module:list
+-----------------------+----------+-------+---------------------------------------------------------+
| Name                  | Status   | Order | Path                                                    |
+-----------------------+----------+-------+---------------------------------------------------------+
| ThemeStore            | Disabled | 0     | E:\wwwroot\object\Modules/ThemeStore            |

3. After enabling the ThemeStore module, the same error still occurs.

Plaintext

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. Finally, I found the cause: Modules\ThemeStore\Providers\ThemeStoreServiceProvider::class in the providers array of config/app.php had been commented out. The service provider class was missing. After uncommenting it, the error no longer occurs.

Plaintext

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.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系