Welcome Guest, Not a member yet? Register   Sign In
Site migration using site_migrate
#1

[eluser]mlieshout[/eluser]
I trying to migrate a rather complex old-fashion php/html site to CI using your site_migrate solution. I’ve put the old site in the views/site_migrate directory and this works.

What I want to do now is to migrate the site page-by-page to the MVC structure.
Somehow, I don’t follow the site_migrate steps as I can only do this by adding the new pages to the site_migrate controller.

What if I want to convert a page from the old site into its own controller and use subdirs in the views.
I.e.:

A page products.php in the old style should become:
controller/products.php

Code:
<?php
class Products extends Controller {

  function Products()
  {
      parent::Controller();
  }
  
  function index()
  {
      $data[‘title’] = “title”;  
      $this->load->view(‘products/index.php’, $data);
  }
}

This is the view in views/products/index.php

Code:
<?php
$this->load->view(‘common/header’,$title);
?>
<div id=“mainWrapper”>
  <div id=“main”>      
          testtest
  </div>
</div> <!—mainWrapper—>
&lt;?php
$this->load->view(‘common/footer’);
?&gt;

But I keep getting these errors:
Quote:A PHP Error was encountered
Severity: Warning
Message: chdir() [function.chdir]: No such file or directory (errno 2)
Filename: controllers/site_migrate_base.php
Line Number: 53
Any idea what might go wrong?
#2

[eluser]sophistry[/eluser]
hi mileshout,

welcome to CI.

the code you posted shouldn't have any interaction with site_migrate! i am curious...

your controller and views seem to be separate from site_migrate so none of the site_migrate code should be called. but, based on the error you posted i can see it is being called.

it's nice to hear that you got site_migrate working.

the way it works is to allow you to create controller functions inside your child controller (sounds like your is called site_migrate). when you name a controller function the same as an existing page, the code flow runs the controller function instead of loading the page as a view. you can of course, just load the page as a view inside the new controller function to make sure the code flow is working! then, you can do the things you normally do in controller functions and slowly but surely, your old site will migrate into the new child controller.

you can have multiple child controllers too.

does the code you posted work in a fresh CI install?
#3

[eluser]mlieshout[/eluser]
I got it working now. The catchall was the problem:

Code:
$route['(:any)'] = 'site_migrate/$1';

If I create a new route for every controller/view that is converted into CI it works like a charm.

Thanks!
#4

[eluser]sophistry[/eluser]
oh yeah! routing.

this is a good time to really consider how you want to handle the CI architecture of your migrated system. it sounds like you are converting 1:1 page to controller. but, you don't have to do that... you can make controllers and then use the controller functions to replace the individual pages. that's better than having dozens of really repetitive controllers.

cheers.
#5

[eluser]manik005[/eluser]
does it works on latest version of CI?
#6

[eluser]sophistry[/eluser]
what did you find out?
#7

[eluser]manik005[/eluser]
i get 500 internal server error
#8

[eluser]sophistry[/eluser]
on a fresh install of CI?
#9

[eluser]manik005[/eluser]
i installed ci and then added my old site in site_migrate folder , then added site_migrate_base and then site_migrate class but i get 500 whn i run it
#10

[eluser]sophistry[/eluser]
just put the site migrate controller in place and test that it is working first before you put the old site in the site_migrate folder. that will let you know if site_migrate code is working. i am testing right now on a CI 2 install, but please report if you are able to run a simple one-page "site" from the site_migrate folder. if you can do that then you know the problem is with the old site and it's interaction inside the new CI host.

what about extensions for the old site? is everything in place and the same as it was on your old hosting machine? PHP version the same? php.ini settings the same?

finally, does the old site work outside of site migrate but on the new hosting machine? or do you get 500 error?




Theme © iAndrew 2016 - Forum software by © MyBB