在 Laravel & 中安全地编辑第三方作曲家(供应商)包防止在发布新版本的软件包时丢失自定义更改

Safely edit a third party composer (vendor) package in Laravel amp; prevent losing customized changes on release of a new version of the package(在 Laravel amp; 中安全地编辑第三方作曲家(供应商)包防止在发布新版本的软件包时丢失自定义更改)
本文介绍了在 Laravel & 中安全地编辑第三方作曲家(供应商)包防止在发布新版本的软件包时丢失自定义更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Laravel 5 项目中编辑从 composer 提取的包,但是我相信如果我运行 composer update 并且该包的新版本已经发布,我将失去所有我的变化.我应该如何去编辑包?有没有办法将包从供应商目录中复制出来,以便我可以在项目的其他地方使用它?

I want to edit a package I pulled from composer in my Laravel 5 project, however i believe that if I ran composer update and a new version of this package has been released, I will lose all of my changes. How should I go about editing the package? Is there a way to copy package out of the vendor directory so I can use it somewhere else in my project?

推荐答案

编辑 composer 包实际上是不安全的,因为你指出的原因.

It actually isn't safe to edit composer packages, for the very reason you point out.

我所做的是扩展我想要/需要更改的类.

What I do is extends the classes that I want/need to change.

我在这里使用 Filesystem 类完成了它.它不能确保它不会中断,但它可以让您在不覆盖更改的情况下进行更新.

I have done it here with the Filesystem class. It doesn't ensure that it won't break, but it does let you update without overwriting your changes.

config/app.php

<?php

return [

    'providers' => [

//        'IlluminateFilesystemFilesystemServiceProvider',
        'MyAppFilesystemFilesystemServiceProvider',
    ],

    'aliases' => [
        ...
    ],

];

MyAppFilesystemFilesystemServiceProvider.php

<?php namespace MyAppFilesystem;

use Config;
use Storage;
use LeagueFlysystemFilesystem;
use DropboxClient as DropboxClient;
use LeagueFlysystemDropboxDropboxAdapter;
use IlluminateFilesystemFilesystemManager as LaravelFilesystemManager;

class FilesystemManager extends LaravelFilesystemManager{

    public function createDropboxDriver(array $config)
    {
        $client = new DropboxClient($config['token'], $config['app']);

        return $this->adapt(
            new Filesystem(new DropboxAdapter($client))
        );
    }
}

这篇关于在 Laravel &amp; 中安全地编辑第三方作曲家(供应商)包防止在发布新版本的软件包时丢失自定义更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)