T
T
topuserman2022-04-18 12:19:20
PHP
topuserman, 2022-04-18 12:19:20

Do-it-yourself autowiring (almost like in symfony)?

Hello! there is a self-written project, with its own controllers, which has to register dependencies for auto-varianging into controller methods.

To register a class for autowaring, you need to use a custom event. And so for each service that I want to register.

I would like to make sure that all classes from a certain directory (for example src/) are automatically registered as services for autowiring.

I wanted to know if there are any libraries, or tools that would simplify such development?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vitaly_74, 2022-04-18
@vitaly_74

Use reflection, ReflectionClass and then do whatever you want, for example, I once made secondary constructors out of it. I think they will help you solve your problem, if you want right from scratch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question