Skip to content

use app container to get request, response, etc... #3

@aarbrown

Description

@aarbrown

Hello,

I ran into an issue where I was extending the slim response in the container for my app and the test was failing because we are creating new Slim\Http\Response's instead of getting them from the app's container in this module.

I only have a need right now to retrieve the response from the container. However, I could imagine that anything that's in the container is fair game for extension. With that in mind, I looked at retrieving the request object from the container but that one seems to be more difficult since we have to inject a mock environment into Slim. Which brings me to why I'm opening this issue.

Currently, this module expects the user to fully instantiate a Slim app inside a DI container. This makes it difficult (perhaps impossible) for the module to inject the mock environment into Slim later down the road which, in turn, makes it difficult for us to use the request in the app's container.

Personally, I think the way the container is structured would have to be changed. Maybe we could require 'middleware' and 'routes' services in the container instead of App::class. Then we could instantiate the slim app with our mock environment and add the middleware and routes from the container to our app.

Of course, if there's a way to just Slim to parse the mock environment after it's instantiated, that would work too.

I'd like to get your thoughts on how we might be able to get around this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions