Return to Snippet

Revision: 50627
at August 29, 2011 12:49 by hotdiggity


Initial Code
<?php
header('Content-type: text/plain');
$contents = explode("n", file_get_contents('pear.ini'));
$data = unserialize($contents[1]);
 
foreach($data as $key => $value) {
    if(is_string($value)) {
        $data[$key] = str_replace('/old/path', '/new/path', $value);
    }
}
 
echo $contents[0] . "n";
echo serialize($data);
?>

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

Initial Description
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.

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

Initial Tags
magento

Initial Language
PHP