PHP code example of bevin1984 / yii2-minio

1. Go to this page and download the library: Download bevin1984/yii2-minio 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/ */

    

bevin1984 / yii2-minio example snippets


"bevin1984/yii2-minio": "^0.0.1"

'components' => [
    'minio' => [
        'class'=> 'bevin1984\MinioClient',
        'key' => '<your key>',
        'secret' => '<your secret>',
        'endpoint'=> '<your endpoint>',
        'region' => '<your region>',
        'bucket' => '<your bucket>'
    ],
]

Yii::$app->minio->write('filename.ext', 'contents');

$stream = fopen('/path/to/somefile.ext', 'r+');
Yii::$app->minio->writeStream('filename.ext', $stream);

$contents = Yii::$app->minio->read('filename.ext');

$stream = Yii::$app->minio->readStream('filename.ext');
$contents = stream_get_contents($stream);
fclose($stream);

Yii::$app->minio->save('filename.ext', '/path/to/somefile.ext');

$exists = Yii::$app->minio->has('filename.ext');

Yii::$app->minio->delete('filename.ext');

Yii::$app->minio->copy('filename.ext', 'newname.ext');

Yii::$app->minio->rename('filename.ext', 'newname.ext');

$mimetype = Yii::$app->minio->getMimetype('filename.ext');

$timestamp = Yii::$app->minio->getTimestamp('filename.ext');

$size = Yii::$app->minio->getSize('filename.ext');

$url = Yii::$app->minio->getObjectUrl('filename.ext');

$url = Yii::$app->minio->getPresignedUrl('filename.ext', 300);
shell
php composer.phar