Laravel:编辑供应商目录中的文件

I am working with laravel and I have installed a package using composer by running this command composer require mailchimp/mailchimp=~2.0.

After that I got a folder 'mailchimp' in the vendor directory. 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. 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.

You can create a custom class which will extend the Mailchimp class and override the function you want. 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(..)