[英]Laravel: Edit file in the vendor directory
I am working with laravel
and I have installed a package using composer by running this command composer require mailchimp/mailchimp=~2.0
. 我正在使用laravel
并且已经通过运行以下命令使用composer安装了软件包composer require mailchimp/mailchimp=~2.0
。
After that I got a folder 'mailchimp' in the vendor directory. 之后,我在供应商目录中得到了一个文件夹“ mailchimp”。 In there, there is a file named Mailchimp.php
that I have to modify, but based on some old posts here, if I modify the file, any time I run the command composer update
, I will loose my changes in the file, just because it is located in the vendor
directory. 在那里,有一个我必须修改的名为Mailchimp.php
的文件,但是根据这里的一些旧文章,如果我修改了该文件,则无论何时运行命令composer update
,我都会在文件中丢失更改,只是因为它位于vendor
目录中。 So is there any option for me to solve this problem ? 那么我有什么选择解决这个问题吗?
I tried using the command php artisan vendor:publish
but I do not get the expected results. 我尝试使用命令php artisan vendor:publish
命令,但没有得到预期的结果。
You can create a custom class which will extend the Mailchimp
class and override the function you want. 您可以创建一个自定义类,该类将扩展Mailchimp
类并覆盖所需的功能。 Then use the custom class in your code. 然后在代码中使用自定义类。
use DrewM\MailChimp\MailChimp;
class CustomMailChimp extends MailChimp {
...
// The function you would like to override
}
Then use it new CustomMailChimp(..)
然后使用它new CustomMailChimp(..)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.