Code Monkey home page Code Monkey logo

Comments (2)

codeliner avatar codeliner commented on May 22, 2024

@moderndeveloperllc You mix the concepts a bit :)
A middleware should not be its own factory. What you can and should do is register a middleware factory as a service in your container.
Then follow the docs to let zend-expressive lazy-load your middleware:

See the lazy-load example. middleware is a service name in the example and used to get the invokeable middleware from the container. When your factory is registered with such a service name it gets the container injected when it is invoked.
See the Factory-Driven Creation of a router for example (a router is a middleware). Same works for any other middleware. Your factory can get further dependencies from the container and create the invokable middleware.

from zend-expressive.

moderndeveloperllc avatar moderndeveloperllc commented on May 22, 2024

@codeliner Yeah - my bad. Never ask a question right before bed! I meant to say have a factory for the middleware in the factories service config, instead of the middleware class as a line in invokables. Thanks for pointing out the example I missed. I would have use a __construct() instead of __invoke() on the factory class.

from zend-expressive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.