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.
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' => [
// 'Illuminate\Filesystem\FilesystemServiceProvider',
'MyApp\Filesystem\FilesystemServiceProvider',
],
'aliases' => [
...
],
];
MyApp\Filesystem\FilesystemServiceProvider.php个
<?php namespace MyApp\Filesystem;
use Config;
use Storage;
use League\Flysystem\Filesystem;
use Dropbox\Client as DropboxClient;
use League\Flysystem\Dropbox\DropboxAdapter;
use Illuminate\Filesystem\FilesystemManager 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))
);
}
}