如何在供应商laravel 4上编辑软件包 [英] How to edit package on vendor laravel 4

查看:58
本文介绍了如何在供应商laravel 4上编辑软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的应用程序中工作,并且正在使用某些软件包,但是我必须在其中进行更改或添加一些逻辑.我读到,当它们位于供应商目录上时,我们一定不要更改软件包的代码,但我没有找到如何做的替代方法.有什么想法吗?

i was working in my application and i'm using some packages, but i have the necessity to change or add some logic in it. I read that we must don't change code of the packages when they are on the vendor directory, but i didn't find how i can do instead. any ideas?

推荐答案

这在软件包之间是不同的.

This differs from package to package.

一种万能的解决方案是分叉该软件包,本质上是将其复制并修改复制版本中的代码.

The one-size-fits-all solution is to fork the package, essentially copying it and modifying code in the replicated version.

通常,程序包可以提供扩展或扩展其工作的方法.这将非常依赖于该程序包,建议您参考它的文档以获取有关该方面的更多帮助.

Often, packages may offer methods to extend or build on their work. This will be very dependent on the package, and I'd suggest you refer to it's documentation for more help down that front.

如果您走第一条路线,则必须注意一些事项:

If you take the first route, you must be aware of some things:

第二次分叉一个软件包,您将负责维护它.

如果分叉该软件包,最终将得到一个由原始作者无法维护的软件包,因为您已对其进行了更改.如果将其保留在composer中并编辑原始软件包,则下次运行composer update时它将被覆盖.此外,如果您要对工作进行版本控制,则不会对您的软件包进行修改.但是如果您正确地分叉它,它将与原始包没有任何关系.这意味着您的软件包可能会过时,除非您花精力维护其更新.

If you fork the package, you will end up with a package that cannot be maintained by it's original author because you have changed it. If you keep it in composer and edit the original package, it will get overwritten the next time you run composer update. Additionally, if you're versioning your work, your package modifications will not be carried across. but if you fork it properly, it will have no ties to the original package. This means that your package may become outdated unless you spend effort maintaining it's updates.

如果您使用的是composer,则很可能涉及派生原始程序包存储库并修改该存储库中的代码. (不要仅对本地软件包文件执行此操作).这可能是最好的解决方案,因为这意味着如果原始存储库已对其包进行了更改,则可以与存储库执行合并以将其更新带入代码中(除非更新确实与代码直接交互,否则不会影响您的更改)您正在修改).从那里,将新的分叉存储库添加到您的composer.json文件中,并对其进行处理.

If you're using composer, this will most likely involve forking the original package repo and modifying code in that repo instead. (Do NOT do this to just your local package files). This is probably the best solution, because it means if the original repo has made changes to it's package, you can perform merges with your repo to bring their updates into your code (whilst not affecting your changes unless the update does directly interact with the code you're modfying). From there, add your new forked repo into your composer.json file and work with that.

这篇关于如何在供应商laravel 4上编辑软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆