简体   繁体   English

如何在供应商laravel 4上编辑包

[英]How to edit package on vendor 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: 如果你采取第一条路线,你必须知道一些事情:

The second you fork a package, you will be responsible for maintaining it. 第二个你分叉一个包,你将负责维护它。

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 . 如果将它保留在composer中并编辑原始包,则下次运行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. 这意味着您的软件包可能会过时,除非您花费精力维护它的更新。

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. 从那里,将您的新分叉存储库添加到您的composer.json文件中并使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM