Laravel 保留对外部库的更改
Laravel preserving changes to external libraries
我已经为 laravel 安装了 jwt auth 库。为了满足我的应用程序的需要,我需要对其进行一些更改。
但是,每当我进行作曲家更新或安装时,更改都消失了。有没有办法阻止这种行为?
我假设你说:
I need to make some changes to it.
您一直在为 jwt 库编辑 vendor
目录中的包文件。 vendor
目录中的任何内容都将被作曲家 update/install 覆盖。因此,您不应该在 vendor
目录中 changing/editing 文件。
您应该考虑以不同的方式使用该库,例如扩展您需要使用的 class,或者您可以分叉该项目并引入您自己的修改版本。
如果您提供有关如何使用它的更多详细信息以及您想对其进行哪些更改,您可能会得到一些关于如何最好地处理它的建议。
编辑
我猜这就是您制作和使用您自己修改后的副本的方式...
在 github 上分叉项目,我假设你正在使用这个 https://github.com/tymondesigns/jwt-auth(因此它在 github)
克隆它以获得本地副本,进行更改,然后将更改推送回 github。然后最后使用 composer 将您的 forked/modified 版本拉入您的项目。然后可以再次从供应商文件夹访问它!
一些进一步的信息:
Loading a package from a VCS repository
There are a few use cases for this. The most common one is maintaining
your own fork of a third party library. If you are using a certain
library for your project and you decide to change something in the
library, you will want your project to use the patched version. If the
library is on GitHub (this is the case most of the time), you can
simply fork it there and push your changes to your fork. After that
you update the project's composer.json. All you have to do is add your
fork as a repository and update the version constraint to point to
your custom branch. Your custom branch name must be prefixed with
"dev-".
我已经为 laravel 安装了 jwt auth 库。为了满足我的应用程序的需要,我需要对其进行一些更改。 但是,每当我进行作曲家更新或安装时,更改都消失了。有没有办法阻止这种行为?
我假设你说:
I need to make some changes to it.
您一直在为 jwt 库编辑 vendor
目录中的包文件。 vendor
目录中的任何内容都将被作曲家 update/install 覆盖。因此,您不应该在 vendor
目录中 changing/editing 文件。
您应该考虑以不同的方式使用该库,例如扩展您需要使用的 class,或者您可以分叉该项目并引入您自己的修改版本。
如果您提供有关如何使用它的更多详细信息以及您想对其进行哪些更改,您可能会得到一些关于如何最好地处理它的建议。
编辑
我猜这就是您制作和使用您自己修改后的副本的方式...
在 github 上分叉项目,我假设你正在使用这个 https://github.com/tymondesigns/jwt-auth(因此它在 github)
克隆它以获得本地副本,进行更改,然后将更改推送回 github。然后最后使用 composer 将您的 forked/modified 版本拉入您的项目。然后可以再次从供应商文件夹访问它!
一些进一步的信息:
Loading a package from a VCS repository
There are a few use cases for this. The most common one is maintaining your own fork of a third party library. If you are using a certain library for your project and you decide to change something in the library, you will want your project to use the patched version. If the library is on GitHub (this is the case most of the time), you can simply fork it there and push your changes to your fork. After that you update the project's composer.json. All you have to do is add your fork as a repository and update the version constraint to point to your custom branch. Your custom branch name must be prefixed with "dev-".