Skip to content

factories use container as service locator and uses classnames as keys.. #23

Open
@ppetermann

Description

@ppetermann

I just stumbled over the middleware and was surprised that the docs said it supports psr-11, wondering what it would load through it.

A quick look at the code revealed several issues:

  • the factory classes all use the container in a ServiceLocator anti-pattern, which is discouraged in psr-11 section.13.
  • the identifier within the container is a classname, a better way would be to use an interface here, and then have the classes implementing the service stored for that interface.
  • for configuration the key "config" is used, which might conflict with the config of some frameworks, furthermore, there is no clear interface, o and even worse the provided ConfigProvider is final, and loads static confic files from its own config dir, that are meant for a specific framework, thus making it a necessity to replace the not-mentioned interfaceless config provider with your own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions