Site Migrate - Easily bring entire websites into a CI system with minimal changes to existing code |
[eluser]sophistry[/eluser]
Recently, I've moved several existing sites into the loving embrace of CodeIgniter. Here is a way to copy a whole website full of HTML and PHP pages into the system/application/views directory and have it working in a CI context within minutes. All the paths remain intact so even though CI is serving the pages, the URIs are all the same as the old site. This technique supports: - URIs are the same between old site and new CI-context site (may need some custom routing in routes.php) - easy drop-in of existing websites with very few changes (minor path changes for image, css, and js assets may be necessary) - nested directories in the views directory - code is 'directory-aware' with default view file name 'index' - code is 'current working directory aware' so relative links in include and require functions work properly - old-school GET queries (you know, with the question mark in the URI... remember those? you used to use them before you started with CI - needs just three config settings changes in config.php to tell CI to allow GET queries into CI) - adding a method in the Child Controller overrides the automatic view file loading (to move the site gradually to MVC setup) Here is the solution: Site Migrate It is one Base Controller (just a few lines long) that you extend with your own child controllers. The wiki page has the full code and a demo child controller for your convenience, but here is what the Base Controller looks like with no comments: Code: <?php Quote: Questions? Suggestions? Brickbats? ;-) p.s. _remap() is cool - thanks to whoever put it in CI. |
Welcome Guest, Not a member yet? Register Sign In |