I cannot get container and dependency injection to work with slim 3

184 Views Asked by At

Im trying to setup dependency injection in Slim v3 but to no avail. I keep getting 127.0.0.1:42766 [500]: GET /composers - Uncaught Error: Class 'Composer\ComposerDataAccess' not found in /home/thor/personal-repos/composers-api/src/public/ioc.php:22 my file structure looks like this:

enter image description here

My class with dependencies I try to add to the container looks like this. The logger and the db seems to work. Just not the classes i added my self.

enter image description here

Im trying to use the dependency in my route like this, but it doesn't work and keep throwing error at me. enter image description here

Edit: I am not a smart man, file names are case sensitive to the autoloader I guess. So renaming the files to start with uppercases did it.

0

There are 0 best solutions below