How to edit package on vendor laravel 4

徘徊边缘 提交于 2019-12-11 10:31:30

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/21727503/how-to-edit-package-on-vendor-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!