在 Laravel 6 中报错:Target [Interface] is not instantiable while building [Resolver]

1、在 Laravel 6 中报错:Target [Interface] is not instantiable while building [Resolver]。如图1

在 Laravel 6 中报错:Target [Interface] is not instantiable while building [Resolver]。

图1

{
    "message": "Target [Modules//ThemeSetting//Schema//ThemeSchemaLoaderInterface] is not instantiable while building [Modules//ThemeStore//Resolver//OnlineStoreThemeResolver].",
    "exception": "Illuminate//Contracts//Container//BindingResolutionException",
    "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
    "line": 978,
    "trace": [
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 812,
            "function": "notInstantiable",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 681,
            "function": "build",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Application.php",
            "line": 785,
            "function": "resolve",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 629,
            "function": "resolve",
            "class": "Illuminate//Foundation//Application",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Application.php",
            "line": 770,
            "function": "make",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 945,
            "function": "make",
            "class": "Illuminate//Foundation//Application",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 873,
            "function": "resolveClass",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 834,
            "function": "resolveDependencies",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 681,
            "function": "build",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Application.php",
            "line": 785,
            "function": "resolve",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Container//Container.php",
            "line": 629,
            "function": "resolve",
            "class": "Illuminate//Foundation//Application",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Application.php",
            "line": 770,
            "function": "make",
            "class": "Illuminate//Container//Container",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//helpers.php",
            "line": 120,
            "function": "make",
            "class": "Illuminate//Foundation//Application",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Support//Utils.php",
            "line": 58,
            "function": "app"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Schema//Directives//FieldDirective.php",
            "line": 45,
            "function": "constructResolver",
            "class": "Nuwave//Lighthouse//Support//Utils",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Schema//Factories//FieldFactory.php",
            "line": 68,
            "function": "resolveField",
            "class": "Nuwave//Lighthouse//Schema//Directives//FieldDirective",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Schema//TypeRegistry.php",
            "line": 369,
            "function": "handle",
            "class": "Nuwave//Lighthouse//Schema//Factories//FieldFactory",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Type//Definition//UnresolvedFieldDefinition.php",
            "line": 39,
            "function": "Nuwave//Lighthouse//Schema//{closure}",
            "class": "Nuwave//Lighthouse//Schema//TypeRegistry",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Type//Definition//TypeWithFields.php",
            "line": 45,
            "function": "resolve",
            "class": "GraphQL//Type//Definition//UnresolvedFieldDefinition",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Type//Definition//TypeWithFields.php",
            "line": 33,
            "function": "findField",
            "class": "GraphQL//Type//Definition//TypeWithFields",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//Rules//OverlappingFieldsCanBeMerged.php",
            "line": 256,
            "function": "getField",
            "class": "GraphQL//Type//Definition//TypeWithFields",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//Rules//OverlappingFieldsCanBeMerged.php",
            "line": 165,
            "function": "internalCollectFieldsAndFragmentNames",
            "class": "GraphQL//Validator//Rules//OverlappingFieldsCanBeMerged",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//Rules//OverlappingFieldsCanBeMerged.php",
            "line": 96,
            "function": "getFieldsAndFragmentNames",
            "class": "GraphQL//Validator//Rules//OverlappingFieldsCanBeMerged",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//Rules//OverlappingFieldsCanBeMerged.php",
            "line": 64,
            "function": "findConflictsWithinSelectionSet",
            "class": "GraphQL//Validator//Rules//OverlappingFieldsCanBeMerged",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Language//Visitor.php",
            "line": 414,
            "function": "GraphQL//Validator//Rules//{closure}",
            "class": "GraphQL//Validator//Rules//OverlappingFieldsCanBeMerged",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Language//Visitor.php",
            "line": 470,
            "function": "GraphQL//Language//{closure}",
            "class": "GraphQL//Language//Visitor",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Language//Visitor.php",
            "line": 277,
            "function": "GraphQL//Language//{closure}",
            "class": "GraphQL//Language//Visitor",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//DocumentValidator.php",
            "line": 224,
            "function": "visit",
            "class": "GraphQL//Language//Visitor",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//Validator//DocumentValidator.php",
            "line": 116,
            "function": "visitUsingRules",
            "class": "GraphQL//Validator//DocumentValidator",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//GraphQL.php",
            "line": 153,
            "function": "validate",
            "class": "GraphQL//Validator//DocumentValidator",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//webonyx//graphql-php//src//GraphQL.php",
            "line": 94,
            "function": "promiseToExecute",
            "class": "GraphQL//GraphQL",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//GraphQL.php",
            "line": 268,
            "function": "executeQuery",
            "class": "GraphQL//GraphQL",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//GraphQL.php",
            "line": 203,
            "function": "executeParsedQuery",
            "class": "Nuwave//Lighthouse//GraphQL",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//GraphQL.php",
            "line": 162,
            "function": "parseAndExecuteQuery",
            "class": "Nuwave//Lighthouse//GraphQL",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//GraphQL.php",
            "line": 121,
            "function": "executeOperation",
            "class": "Nuwave//Lighthouse//GraphQL",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Support//Utils.php",
            "line": 99,
            "function": "Nuwave//Lighthouse//{closure}",
            "class": "Nuwave//Lighthouse//GraphQL",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//GraphQL.php",
            "line": 120,
            "function": "applyEach",
            "class": "Nuwave//Lighthouse//Support//Utils",
            "type": "::"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Support//Http//Controllers//GraphQLController.php",
            "line": 32,
            "function": "executeOperationOrOperations",
            "class": "Nuwave//Lighthouse//GraphQL",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//ControllerDispatcher.php",
            "line": 48,
            "function": "__invoke",
            "class": "Nuwave//Lighthouse//Support//Http//Controllers//GraphQLController",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Route.php",
            "line": 219,
            "function": "dispatch",
            "class": "Illuminate//Routing//ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Route.php",
            "line": 176,
            "function": "runController",
            "class": "Illuminate//Routing//Route",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php",
            "line": 681,
            "function": "run",
            "class": "Illuminate//Routing//Route",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 130,
            "function": "Illuminate//Routing//{closure}",
            "class": "Illuminate//Routing//Router",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Support//Http//Middleware//AttemptAuthentication.php",
            "line": 34,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Nuwave//Lighthouse//Support//Http//Middleware//AttemptAuthentication",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//nuwave//lighthouse//src//Support//Http//Middleware//AcceptJson.php",
            "line": 27,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Nuwave//Lighthouse//Support//Http//Middleware//AcceptJson",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 105,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php",
            "line": 683,
            "function": "then",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php",
            "line": 658,
            "function": "runRouteWithinStack",
            "class": "Illuminate//Routing//Router",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php",
            "line": 624,
            "function": "runRoute",
            "class": "Illuminate//Routing//Router",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php",
            "line": 613,
            "function": "dispatchToRoute",
            "class": "Illuminate//Routing//Router",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Kernel.php",
            "line": 170,
            "function": "dispatch",
            "class": "Illuminate//Routing//Router",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 130,
            "function": "Illuminate//Foundation//Http//{closure}",
            "class": "Illuminate//Foundation//Http//Kernel",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//barryvdh//laravel-debugbar//src//Middleware//InjectDebugbar.php",
            "line": 67,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Barryvdh//Debugbar//Middleware//InjectDebugbar",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//app//Http//Middleware//ChangeAppUrlMiddleware.php",
            "line": 23,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "App//Http//Middleware//ChangeAppUrlMiddleware",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//TransformsRequest.php",
            "line": 21,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Illuminate//Foundation//Http//Middleware//TransformsRequest",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//TransformsRequest.php",
            "line": 21,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Illuminate//Foundation//Http//Middleware//TransformsRequest",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Illuminate//Foundation//Http//Middleware//ValidatePostSize",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//CheckForMaintenanceMode.php",
            "line": 63,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Illuminate//Foundation//Http//Middleware//CheckForMaintenanceMode",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//fideloper//proxy//src//TrustProxies.php",
            "line": 57,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Fideloper//Proxy//TrustProxies",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//dingo//api//src//Http//Middleware//Request.php",
            "line": 111,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 171,
            "function": "handle",
            "class": "Dingo//Api//Http//Middleware//Request",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php",
            "line": 105,
            "function": "Illuminate//Pipeline//{closure}",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Kernel.php",
            "line": 145,
            "function": "then",
            "class": "Illuminate//Pipeline//Pipeline",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Kernel.php",
            "line": 110,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate//Foundation//Http//Kernel",
            "type": "->"
        },
        {
            "file": "E://wwwroot//wshop//platform//public//index.php",
            "line": 57,
            "function": "handle",
            "class": "Illuminate//Foundation//Http//Kernel",
            "type": "->"
        }
    ]
}

2、查看 /Modules/ThemeStore/Providers/ThemeStoreServiceProvider.php,提示 未定义的类 ‘ThemeSchemaLoaderInterface’。如图2

查看 /Modules/ThemeStore/Providers/ThemeStoreServiceProvider.php,提示 未定义的类 'ThemeSchemaLoaderInterface'。

图2

3、但是,可以确认 类 ‘ThemeSchemaLoaderInterface’ 是存在的。最后发现 use 的路径有误。删掉掉路径中的 Theme/。IDE 不再提示。如图3

但是,可以确认 类 'ThemeSchemaLoaderInterface' 是存在的。最后发现 use 的路径有误。删掉掉路径中的 Theme/。IDE 不再提示。

图3

4、执行命令:php artisan list 时报错:Illuminate/Contracts/Container/BindingResolutionException : Target class [Modules/ThemeStore/Console/AssetCdn/SyncCommand] does not exist.

PS E:/wwwroot/wshop/platform> php artisan list

   Illuminate/Contracts/Container/BindingResolutionException  : Target class [Modules/ThemeStore/Console/AssetCdn/SyncCommand] does not exist.

  at E:/wwwroot/wshop/platform/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
    801|
    802|         try {
    803|             $reflector = new ReflectionClass($concrete);
    804|         } catch (ReflectionException $e) {
  > 805|             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    806|         }
    807|
    808|         // If the type is not instantiable, the developer is attempting to resolve
    809|         // an abstract type such as an Interface or Abstract Class and there is

  Exception trace:

  1   ReflectionException::("Class Modules/ThemeStore/Console/AssetCdn/SyncCommand does not exist")
      E:/wwwroot/wshop/platform/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

  2   ReflectionClass::__construct("Modules/ThemeStore/Console/AssetCdn/SyncCommand")
      E:/wwwroot/wshop/platform/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

  Please use the argument -v to see more details.
PS E:/wwwroot/wshop/platform>

5、查看 /Modules/ThemeStore/Providers/ThemeStoreServiceProvider.php ,确定 Consoles/AssetCdn/SyncCommand::class 在相应路径下不存在。删除掉相应的调用。如图4

查看 /Modules/ThemeStore/Providers/ThemeStoreServiceProvider.php ,确定 Consoles/AssetCdn/SyncCommand::class 在相应路径下不存在。删除掉相应的调用。

图4

6、再次执行命令:php artisan list 时成功。

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/webdev/250730.html

(0)
上一篇 2022年5月1日 03:42
下一篇 2022年5月1日 03:46

相关推荐

发表回复

登录后才能评论