Package namespace

I don’t want to specify the full path to a packages. How I can indicate in DI where to look for a package? For example, by default my packages located in app\api directory, but packages “don’t know” their fact location and try to find own classes starts with package namespace, then I get errors like Registration\User is not defined.

phpDI with autowiring true, and you don’t care for anything at all.
There is a little issue if you have to inject an array or variable into constructor. You can handle with that by wrapping them into some config class and you have a problem out of your head :slightly_smiling_face:, although you can actually find yourself in a situation where some things are just unavoidable.

On the other hand, boring, manual declarations of dependencies makes application working much faster, so there is always something for something.

1 Like