Invokable Class Constructors

I am reviewing @odan’s skeleton for Slim 4. There is one thing that is baffling me. For routes, he is using invokable classes. I totally understand that. But what is confusing in that some of the corresponding Action classes have a constructor that has a dependency loading as an argument. I don’t understand where/how these invokable classes get generated. How do I define what needs to get passed to them.

I notice similar things going on when adding Middleware via invokable classes.

I feel that this is the last bit that I need to understand before I can start running on my own.

Eighter there a depenency injection container configuration somewhere or its a DIC which supports autowiring and @odan takes use of it.

Hi @joeworkman

The odan/slim4-skeleton uses a dependency injection container that wires the class dependencies with a combination of factories and autowiring. Classes that must be created manually, like the database connection are created in factories. Other classes don’t need a factory, because they can be created automatically using autowiring.

1 Like

It was the autowiring! Man, that was driving me nuts. It was “just working” but I hate not knowing why. Thanks!

1 Like