Illuminate/Container.php

I’m really stumped with this one, any help would be greatly appreciated. Reading through the xDebug logs, and searching through files I’m not getting any nearer to a solution.

My site functions without issue when xDebug is off, however, with xDebug on I can’t get past this exception caused by illuminate and it’s making debugging anything else impossible.

Exception has occurred.

Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Container\Container] is not instantiable while building [Illuminate\Events\Dispatcher].

It looks like something during the process of building blade templates is going wrong but I can’t narrow down where the error is in my code. I’ve systematically deleted each element invoked within app.blade.php in resources/views/ to see if there was a partial element that contained the error but the exception was thrown every time. Here’s my call stack:

Looking at the Variables pane, there seems to be an endless number of instances related to the $this local var.

My launch.json file looks like this:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/srv/www/clientSite/current/web": "${workspaceFolder}/site/web"
            }
        }
    ]
}

FWIW, this thread did not help me resolve my issue. Xdebug in VS Code – working for anyone? - #5 by Andreas_Olsson

Thanks in advance.

1 Like

Hey @strangeways - I’m able to reproduce this, but haven’t found a solution. In my case, though, I’m able to continue past the exception and it will then move on to any subsequent exceptions, breakpoints, etc. It sounds like you’re not able to press “Continue” and move on to the thing you really want to debug?

2 Likes

A couple of workarounds:

  1. By default, the debugger in VS Code stops on “Everything”. If you change it like this, you’ll still stop on errors in your code but not on thrown exceptions, which may be fine for you:

    image

  2. In your launch.json, you can ignore errors from certain files:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Listen for XDebug",
                "type": "php",
                "request": "launch",
                "port": 9000,
                "pathMappings": {
                    "/srv/www/clientSite/current/web": "${workspaceFolder}/site/web"
                },
                "ignore": ["vendor/**/*.php"]
            }
        ]
    }
    
1 Like

Matt, thank you so much for taking the time to help me with this. I’m implementing your workarounds to restore sanity to this project but I’m curious how you reproduced the exception? I’m combining one of htmlstream’s bootstrap themes (Space) with Sage and not sure when this exception cropped up during the process.

1 Like

Hey @strangeways - I just set up xdebug and as soon as I fired it up with a copy of Sage I keep on hand for testing things, I ran into the Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Container\Container] is not instantiable while building [Illuminate\Events\Dispatcher]. exception you mentioned. Not sure if it’s a Sage issue or an xdebug issue or what, and unfortunately didn’t have much luck troubleshooting the message itself, rather than just working around it.

This topic was automatically closed after 42 days. New replies are no longer allowed.