I’d like to use Symfony’s Dependency Injection in my own package.
But I need my package to be compatible with different versions of Symfony (because it needs to work on different versions of Drupal). I don’t want to maintain two different branches just for this.
What I’d like to do is use symfony/dependency-injection only as a dev dependency, and during development, compile the DI container to a class that I’d include in the package repo. That way, projects that use this package can have whatever version of symfony/dependency-injection they want and there won’t be a clash.
For that, I would need the dumped DI class to not have any dependency on the DI package, and be self-contained.
I can see that the DI Dumper has an option to set the compiled container’s base class, so I could set that to a custom class, and in that define some of the expected methods for the base (I don’t need all the features of DI, so just get() would probably be enough).
Is there a cleaner way of doing this?
Source: Symfony Questions
Was this helpful?
0 / 0