PHP code example of stupiddev / flysystem

1. Go to this page and download the library: Download stupiddev/flysystem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stupiddev / flysystem example snippets



/**
 * Minio Connector Class
 * User: hocvt
 * Date: 11/9/18
 * Time: 16:27
 */

namespace App\Colombo\Minio;


use GrahamCampbell\Flysystem\Adapters\AwsS3Connector;

class MinioConnector extends AwsS3Connector {
    
    protected function getAuth( array $config ) {
        
        $auth = parent::getAuth( $config );
        
        if (array_key_exists('use_path_style_endpoint', $config)) {
            $auth['use_path_style_endpoint'] = $config['use_path_style_endpoint'];
        }
        return $auth;
    }
    
}

'minio' => [
        'driver'          => \App\Colombo\Minio\MinioConnector::class,
        'key'             => '0NTTRHXQDBWE0N2Y9YEB',
        'secret'          => 'VC7rw7X4nA1ZJgx8SOIoh6fBmQjVl0JFOnk4vkTz',
        'bucket'          => 'local',
        'region'          => '',
        'version'         => 'latest',
        'bucket_endpoint' => false,
        'use_path_style_endpoint' => true,// this will be passed to S3Client
        // 'calculate_md5'   => true,
        // 'scheme'          => 'https',
         'endpoint'        => 'http://127.0.0.1:9000',
//       'prefix'          => '',
        // 'visibility'      => 'public',
        // 'pirate'          => false,
        // 'eventable'       => true,
        // 'cache'           => 'foo'
    ],

        'Flysystem' => GrahamCampbell\Flysystem\Facades\Flysystem::class,

use GrahamCampbell\Flysystem\Facades\Flysystem;
// you can alias this in config/app.php if you like

Flysystem::put('hi.txt', 'foo');
// we're done here - how easy was that, it just works!

Flysystem::read('hi.txt'); // this will return foo

use GrahamCampbell\Flysystem\Facades\Flysystem;

// note the foo connection does not ship with this package, it's hypothetical
Flysystem::connection('foo')->put('test.txt', 'bar');

// now we can read that file
Flysystem::connection('foo')->read('test.txt'); // this will return bar

use GrahamCampbell\Flysystem\Facades\Flysystem;

// writing this:
Flysystem::connection('local')->read('test.txt');

// is identical to writing this:
Flysystem::read('test.txt');

// and is also identical to writing this:
Flysystem::connection()->read('test.txt');

// this is because the local connection is configured to be the default
Flysystem::getDefaultConnection(); // this will return local

// we can change the default connection
Flysystem::setDefaultConnection('foo'); // the default is now foo

use GrahamCampbell\Flysystem\FlysystemManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class Foo
{
    protected $flysystem;

    public function __construct(FlysystemManager $flysystem)
    {
        $this->flysystem = $flysystem;
    }

    public function bar()
    {
        $this->flysystem->read('test.txt');
    }
}

App::make('Foo')->bar();
bash
$ php artisan vendor:publish