I have a legacy application which is built upon an old custom MVC framework which I'd like to eventually move away from. This framework does not rely on a single front controller, so most pages still have dedicated php files to call the respected controller, others are mixed php/html. I've read up on migrating applications to symfony using various methods (https://symfony.com/doc/current/migration.html), but I've had issues with both methods and have come to the realization that I don't really need symfony's route handling.
Symfony currently exists in our application, but is only used by various commands. All of our core logic is still in the legacy application, so Symfony can access it no problem as the classes are all in the global namespace. However, the problem is, the legacy application cannot utilize any of the new Symfony classes as it does not support dependency injection. This ability would be needed in order to start moving some of our core logic and features to Symfony.
Ideally what I'd like to be able to accomplish is loading in the container to our legacy application, which has all of our autowired services available. Allowing me to access our new Symfony based services, in our legacy application.
Any help is greatly appriciated.
Thank you very much.
Update 1
So I tried what @Cerad said, just access the kernel as it's global. I copied over the bootstrap.php logic to my main config for my legacy application (so it loads up the existing .env* files), then booted the kernel (instantiated it and called boot in my legacy config). It works, I can reference $kernel (using global $kernel) in my php files and access the container. However, which this is inline with @Dmitry Solovov's response, the services must be public.
Must I set all services I want available as public? If I manually define the service in services.yaml, set it to public, it works.
But this isn't really ideal as I would like to autoload my services, so I can use services the correct way and not have to explicitly define each service I want available in my legacy app.
How might I inject services into my legacy controllers, without making the service public? Just like how Symfony's controller allows you to inject services into Controller methods?
Thanks a lot.