Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Porting a website from Symfony 1.4 to 2.0

I've got a huge site that has been written (in a very bad way) in symfony 1.4 now, I've been asked to make some substantial changes to the navigation flow, add some features and so on.. considering the effort, I was wondering if it would be better to take the radical decision to port the entire website to symfony 2.0, but I'm not sure how hard that it could be.

Has anybody ever done this before?

Do you have any suggestion to make for patterns to follow, or tutorials or doc or whatever?

like image 949
holographix Avatar asked May 22 '12 10:05

holographix


2 Answers

You may wrap your legacy project in a brand new sf2 project, by using this bundle. This way, you'll be able to migrate your project one piece at a time, and new functionalities may be developed with sf2 as soon as you get the wrapper to work. You may be interested by this post about migrating

like image 108
greg0ire Avatar answered Sep 23 '22 02:09

greg0ire


Here's how I would go about it:

You need to learn and study some things first:

  • HTTP fundamentals
  • PHP namespaces, which are heavily used
  • Symfony2 documentation
  • Symfony2 documentation
  • Symfony2 documentation
  • PHPUnit documentation

Then when you get the hang of Symfony2, you need to find out what to reuse from your old project:

Models, business logic? Did you use Doctrine in symfony? If yes, look at how to port your entities to Doctrine2, and learn about the differences. If you used Propel, I would look at switching to Doctrine2 and not use the PropelBundle, atleast until you get used to Symfony2. You can find better documentation and sample code out there for Doctrine2.

You also need to convert your old helpers classes to Symfony2 services.

Views? Symfony2 uses Twig as templating engine, but you could go with pure PHP.

Controllers? This should feel somewhat similar to symfony. The flow of Symfony2 matches the HTTP flow, meaning you get a Request object and must reurn a Response object.

It really depends on how well structured our old project is. Symfony2 is an entirely different beast than 1.0-1.4. I would probably not call it a port, but a rewrite - however, if your old project is well structured you could probably reuse quite a bit.

Without actually seeing your code, it's impossible to give a good answer on how hard it would be. It's very much doable, but there is no easy route. Symfony2 is, IMHO, the way of the future for PHP projects and in the end you will get a project that is much easier to maintain and support.

like image 40
cvaldemar Avatar answered Sep 24 '22 02:09

cvaldemar