"Class not found" when injecting dependency

I’m using DI-PHP as the container.

I have a controller class named “Users” and I’m trying to pass the “UserModel” to it’s constructor.


$container->set('Database', function() use ($config){
  return new PDO(...);

$container->set('Users', function(ContainerInterface $c){
  return new \Controller\Users(
    $c->get('UserModel') // this is line 23

$container->set('UserModel', function(ContainerInterface $c){
  return new \Models\UserModel($c->get('Database'));

Basically when I remove $c->get('UserModel') from the Users container, everything works. I think I might be misunderstanding how DI works, but this is the error:

  1. file: “…Core\services.php”
  2. line: 23
  3. message: “Class ‘Models\Planner’ not found”
  4. type: “Error”

We only see class Models\UserModel and not class Models\Planner.
Please show us line 23 of services.php.