开发者

Apply patch file to Magento core files

I edit开发者_C百科 some core code of magento. After this I would like to patch all my edited files to the Magento directory.

My question is: How can I implement php patch with magento? Or how to create patch file with PHP.

Please help me.


Pathfiles are great way to record & distribute you local modifications. Creating a patch file is relatively easy, and applying a patch is even easier.

Before you begin, how did you retrieve Magento's source file?

If you've checkout the source code with SVN, generating a patch is pretty simple.

shell $> cd path/to/your/working/copy
shell $> svn diff > ~/Desktop/magento.path

However, if you downloaded Magento from an archive (tar,zip), you'll need to have the copy of the original files before comparing your revisions. I like to make a original file backup, cp source.php source.php.org, before I alter anything. Sometimes I forget, and I'll need extract the original source-code to a new directory for comparison. To generate a patch file by comparing two sources, use the diff command

shell $> diff -Naur path/to/original/copy path/to/your/working/copy > ~/Desktop/magento.patch

To apply your newly created patch, use the patch command.

shell $> cd path/to/new/magento
shell $> patch -p0 < ~/Desktop/magento.patch

Piece of cake.

Now your question implied that you may want PHP to apply patches. If you comfortable with compiling PHP extentions, take a look at xdiff's xdiff_file_patch function. Else, simply run the previous commands through PHP's system or shell_exec methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜