Stumbled on an issue today where PHP-DI was creating new instances of objects for autowiring and get() function instead of injecting the same instance everywhere. This was difficult to debug, since there’s not a lot of information about the library online. As always, looking at the github issues page led me to the solution.
I was prepending a backslash to the namespaces of objects:
$messageBag = $this->container->get('\Plasticbrain\FlashMessages\FlashMessages');
But apparently the FQN should not contain a leading slash. This is the correct way:
$messageBag = $this->container->get('Plasticbrain\FlashMessages\FlashMessages');
Hope this saves someone an hour or two.