Author of PHP-DI here. Is there a reason why you want to keep Symfony's container?
You said you would be open to use PHP-DI with Symfony's container, so FYI there's an integration possible with the documentation available here. However I don't think it will suit you because it's an integration with the whole Symfony framework. If you want to know how it works, check out the GitHub project.
Now another solution, which might be better, would be to use both Symfony's container and PHP-DI. You can use Acclimate for that. Here is a quick example (not tested):
$sfContainer = /* ... */;
$phpdiContainer = /* ... */;
// Adapt Symfony's container. PHP-DI doesn't need this because it is compliant with
// Container Interop https://github.com/container-interop/container-interop
$acclimator = new ContainerAcclimator;
$sfContainer = $acclimator->acclimate($sfContainer);
$container = new CompositeContainer([$sfContainer, $phpdiContainer]);
Here, the composite container ($container
) will first look for services in Symfony's container, then in PHP-DI's container.
Now the trick is that each container don't know about the other one. So if you use PHP-DI's annotations, you can't inject Symfony's services. But PHP-DI is awesome (hell yeah :p) so you can make it aware of the parent container (which is the composite container) using ContainerBuilder::wrapContainer()
:
$container = new CompositeContainer();
// Add Symfony's container
$container->addContainer($acclimate->adaptContainer($symfonyContainer));
// Configure PHP-DI container
$builder = new ContainerBuilder();
$builder->wrapContainer($container);
// Add PHP-DI container
$phpdiContainer = $builder->build();
$container->addContainer($acclimate->adaptContainer($phpdiContainer));
// Good to go!
$foo = $container->get('foo');
This is taken from PHP-DI's documentation.
Now all is good in the world. The only problem left is that Symfony doesn't know PHP-DI's services, but Symfony's container don't have an equivalent feature, so there's no way around that (that's too bad). In my experience, I don't find it a big problem.
But all in all, I would advise you to use only PHP-DI and everything will be much simpler.