Coldfusion to PHP
Though, determining the exact strategy to port websites from coldfusion to php requires a look at the code and the data, I found that many times, in my experience, ports are not as daunting as they looks for most sites.
Porting Process cheat sheet
Indeed, most of the sites involved a relatively straight forward process and below, you will find a summary of how I approached the porting process: colfusiontophp
Process Explained
This process involves the following phases:
- Picking a platform – When possible, my favorite method is to go with an off the shelf CMS like Wordpress or Drupal, importing the data with into custom content types and write custom plugins when needed. This allows quicker ports and you get to inherit a complete backend and tons of third party plugins - in some cases, it only involves porting the data an theming it.Depending on the amount of pages and actual site code, a preliminary quick port through a simple coldfusion to php conversion may be a good idea (and sometimes enough for simple micro sites). For more complex websites, I would pick an MVC platform such as Code igniter which I find flexible and powerful. It also has a lot of builtin functionality such as caching and form validation and offers one of the best compromises between performance and features.
- Importing the data – This phase can be further broken up into 2 parts:
- table conversion – The actual table conversion from MSSQL to mySQL can probably be handled with dataload enterprise edition (I ported gigabytes of data with it)
- Query conversion – Many queries have to be modified due to slight syntax differences between engines but most modifications are minor such as modifying field name syntax from [fieldname] to
fieldname
or changing function name (example top 5 gets converted to limit 5). Rarely a missing feature will need a workaround, but no big deal (example: full join become union of left joins & right join+many times left join enough)
- Reimplementing existing functionality – That includes user data, social plugins, site specific features, etc
- Legacy url support – If you have a high traffic site, a lot of sites already point to you so there needs to be a legacy url forwarding scheme. If you have an mvc framework like code igniter, routing rules can be builtin to forward to the new location. Otherwise, a few mod_rewrite regular expressions redirecting either to the new url or to a legacy url handling php script is your best bet (for performance, try to have as few rules as possible in htaccess).
- Scaling – Optimizing for million visits is a challenge but not impossible. For example, by simply enabling APC cache, using simple DB & Apache tuning/simple, a previous site I worked on a small amazon instance increased its performance by ten and benchmarked 250 requests per second (about 10M hits per month). Obviously, actual site performance depends on final site but not impossible to achieve. For more tips on scaling, take a look at my post on scaling.
- Making things reliable – this phase includes making sure everything is backed up and there is adequate monitoring. This would also involve things like scripting the install process, documenting and creating a failsafe plan.
Porting tips
- Do not over-plan - One thing to be careful about is over-planning the port and remember the KISS principle (Keep it simple and sweet). Though careful planning is important, in my experience it is best to start with manageable chunks (starting with the data) and integrate complexity as you go along as hurdles are easier to overcome and you get a working site much faster. Also, by having a working demo, even if it is incomplete, it is easier to adapt it to needs as you go along.
- Focus on the data first - The most tricky part is be porting over the tables and the queries. Once this part is done, the complexity of the port is drastically diminished. Further, the best option will be more obvious. Tables should be straight forward if you use a tool for that (I personally like db loader, totally worth it in my experience) but in some cases the migration tool from mysql works too.
- Try to importing into a CMS first - Once data is into mysql, try to get import the data straight into custom content types of an existing CMS like Wordpress or Drupal. Both platforms are relatively flexible and you inherit a fairly complete backend and many plugins. As a side bonus, in some cases, if the cms can handle it, you may not have to bother rewriting frontend logic as well. Obviously, for more complex sites, custom features will have to be implemented through custom plugins but you will have a working site quicker.
- Simple coldfusion to php may be an option - A lot of sites use very simple features in cold fusion features such as cfinclude and cfquery. I find that in many cases, a few judicious search and replace may be able to do the job. The drawback works best for getting a quick port but not as easy to integrate features such as caching.
When it comes to coldfusion templates, the simplest way is to use include files when working with simple ports. If you are using a CMS, then developing a theme for it is relatively straight forward.