MasoniteFramework / debugbar

A Python Debugging tool
MIT License
9 stars 2 forks source link

Does not work with M4 M4 - Binding not found #38

Closed circulon closed 2 years ago

circulon commented 2 years ago

Whats the issue?: I want to use the debug bar in M4

Steps to replicate this: Install a basic M4 Project Install the debug bar as per the docs - as per the docs here Publish the atrifacts for the debug bar into storage - as per the docs here See the exception during publish due to incorrect application binding.

  File ".../venv/lib/python3.9/site-packages/masonite/container/container.py", line 112, in make
    raise MissingContainerBindingNotFound(
masonite.exceptions.exceptions.MissingContainerBindingNotFound: storage key was not found in the container

Notice that storage is not actually part of the bindings in the M4 Kernel

What would you expect?: This binding should be part of the setup as per the M4 Kernel as it is supposed to work with M4 but the bindings impy its still part of M3

josephmancuso commented 2 years ago

Cannot reproduce using the steps you provided. You should not be getting that storage key binding error. that should bind to the container in the StorageProvider. Do you have that provider in your project?

josephmancuso commented 2 years ago

although what does this mean? "Publish the atrifacts for the debug bar into storage - as per the docs here"

josephmancuso commented 2 years ago

Oh i see the issue. The DebugProvider should be the last provider in the PROVIDERS list. You probably have it above the StorageProvider

circulon commented 2 years ago

@josephmancuso

Oh i see the issue. The DebugProvider should be the last provider in the PROVIDERS list. You probably have it above the StorageProvider

Yes the debug bar is the last provider added so thats not the issue. In M4 there is no StorageProvider at all! The Kernel uses the FilesystemProvider to setup storage locations.

    def register_storage(self):
        storage = StorageCapsule()
        storage.add_storage_assets(config("filesystem.staticfiles"))
        self.application.bind("storage_capsule", storage)

        self.application.set_response_handler(response_handler)
        self.application.use_storage_path(base_path("storage"))

As you can see there is no storage binding, only the newer storage_capsule

Hence the Publish error

circulon commented 2 years ago

although what does this mean? "Publish the atrifacts for the debug bar into storage - as per the docs here"

Apologies I thought the inference was obvious.
The Readme on this repo notes

Lastly, publish the provider:

$ python craft package:publish debugbar
josephmancuso commented 2 years ago

@circulon I think something else is going on here. Are you sure you didn't remove that provider somehow? The provider is registered on new projects in the config/providers.py file: https://github.com/MasoniteFramework/cookie-cutter/blob/4.0/config/providers.py#L42.

Running that command on a new project gives me this:

Screen Shot 2022-06-19 at 9 34 02 PM

I think the issue is you're just missing that StorageProvider. You should add it to your project

circulon commented 2 years ago

@josephmancuso

I'm sorry there is a StorageProvider which I completely missed. Apologies.

And yes you were correct in that the debug bar was being loaded prior to the registration of the StorageProvider.

I have a bug in my provider loading which created this Red Herring.

Thanks for the help in getting this working

EDIT: Its working as expected which is very helpful and will make debugging much easier. Cheers for the help.