I just got a job back in corporate america, and I have inherited a nasty bunch of php 4 flat files. I want to migrate to Symfony 2, but there is no way I'll get permission to re-factor the whole thing.
Does anyone have any suggestions for migrating small parts or sections of a project to Symfony 2? Perhaps I could have a directory with the entire old code base and start by only using the routing in Symfony 2 to grab the old flat files?
If anyone has any suggestions I'd love to hear them.
First of all, have you asked whether they'll let you refactor the application? You can build a business case based on:
A full re-factor may not be as complicated or time consuming as you envision, and it can be done in parallel while maintaining the old app.
Now, doing what you suggest is a bit more tricky. You have to consider the following:
If the above points are not an issue, you may get away with adding the php4 structure to the web folder so that they can be accessed directly, and start replacing routes one by one as you build each screen out in Symfony.
These suggestions are very contextual. It really depends on how complex your application is, and how messy it really is.
Good luck tho!
First of all, put a custom made front controller as a front-end to those flat files.
You can redirect old urls to the new front controller with mod_rewrite
.
RewriteRule ^/?(.*) /index.php/$0
# this shall work in .htaccess (/paths) and in httpd.conf (non slashed local paths)
Paths can then be retrieved in index.php trough $_SERVER['PATH_INFO']
From the front controller you can handle some fine grained gradual redirections to any canned solution you wish to move to. For the URLs for whom you want to preserve old functionality, some include("./".$_SERVER['PATH_INFO'])
shall do the trick.
My advice is to break it out into steps. Often management will accept a series of small cost much more readily than a one time big cost. I'd focus on getting the code cleaned up and PHP5 ready before migrating to Symfony2.
Once the code is clean, integrating Symfony2 into your project should be pretty easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With