Pear.ini updater script for Magento (when moving server)


/ Published in: PHP
Save to your folder(s)

Lastly, in order to make magento connect to work correctly edit the pear.ini (downloader/pearlib/pear.ini) and update al the paths that you see in this file. Otherwise magentoconnect will try to upgrade your old site when you use it.

(the files downloader/pearlib/pear downloader/pearlib/peardev downloader/pearlib/pecl may also need the paths updating if you have changed the path)

(Note: Updating this file -pear.ini- is a tedious job, because when you change the paths, you also need the update the field before it which starts with “s:”. You need to type in the length of characters of the path field that you have updated.)

A simple helper script to generate a new the pear.ini file: drop your old pear.ini in the same directory as the PHP script, adjust the paths in the script, open it in a browser and paste the contents into your new pear.ini.

Note: The code splits the ini file into lines by detecting the “n” character - depending on the operating system you are running on the correct new line character to split your file may vary.


Copy this code and paste it in your HTML
  1. <?php
  2. header('Content-type: text/plain');
  3. $contents = explode("n", file_get_contents('pear.ini'));
  4. $data = unserialize($contents[1]);
  5.  
  6. foreach($data as $key => $value) {
  7. if(is_string($value)) {
  8. $data[$key] = str_replace('/old/path', '/new/path', $value);
  9. }
  10. }
  11.  
  12. echo $contents[0] . "n";
  13. echo serialize($data);
  14. ?>

URL: http://www.magentocommerce.com/wiki/groups/227/moving_magento_to_another_server

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.