Answer the question
In order to leave comments, you need to log in
How to include symfony2 in an existing project?
Good afternoon. While working on an old project, the task arose to port it to Symfony. Moreover, it is not immediately transferred, but new modules should be written in symfony, and the old ones should be finalized on the old engine, working in parallel. Tell me, who faced such problems? Or how to make symfony work with a third party engine? So that calls go from third-party code to symfony code (generally, I'm going to put it in different directories). Thanks for the good thoughts and ideas ;)
Answer the question
In order to leave comments, you need to log in
1) make a PSR-7 adapter (or HttpKernel) to your engine
2) make an application for symphony
3) set a middleware that will resolve which application to send which requests. This can be resolved through nginx but somehow not cool.
4) when we start to cut the functionality on the symphony and we need to reuse something from the old code base, we try to separate what we want to use from the old infrastructure (we can say a service decorator for the old engine) and register it in DI
5) we gradually transfer the code, model can be left old if possible.
In fact, the main difficulty is to separate the model from the engine infrastructure and clean up the service layer.
Symfony is a framework. One of the features of the framework is that it calls user code, and not vice versa.
So if you need to make a project in symfony - You need to completely redo it in symfony (make it so that symfony calls your code).
Or there is an option to use separate components of the symphony, using them as you like.
You can implement communication between the old engine and the new engine through a special API. That is, the engines are not programmatically connected, they communicate only through HTTP requests.
Very simple.
Take a symphony and rewrite the routing, controllers and middleware (this is 5-10% of the project volume).
Models and view leave the old ones.
And when creating new functionality or refactoring, you are already working with doctrine (as part of the task).
Now we are integrating Silex into the project in the same way.
The old code is generally noodles in php in places.
We put silex in parallel with the old engine, because all it needs is index.php in the root of the web folder. Our routing was not affected, because there were no beautiful urls in the old engine.
New sections - respectively, on silex, we write our own classes. The important thing is that we set up an autoloader for new classes so that they can be used in old files.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question