skylineos/yii2-s3manager

A yii2 extension for managing files in AWS S3 buckets

Installs: 175

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

Language:JavaScript

Type:yii2-extension

4.1.4 2022-01-12 13:55 UTC

This package is auto-updated.

Last update: 2022-01-12 13:59:41 UTC


README

A Yii 2 extension for managing files in AWS S3 buckets


This extension provides a very customizable method for managing files in AWS S3 buckets for the Yii framework 2.0. It can function on it's own, as a callback for a form field, or integrated with TinyMCE.

For license information check the LICENSE-file.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skylineos/yii2-s3manager

or add

"skylineos/yii2-s3manager": "~3.0.0"

to the require section of your composer.json.

Configuration

To use this extension, you should add the module to your web configuration. Configuration of the module itself can be done here or on the fly.

return [
    //....
    'modules' => [
        's3manager' => [
            'class' => 'skylineos\yii\s3manager\Module',
            // All settings can be configured on the fly regardless of usage type (fileinput, standalone manager, tinymce plugin)
            'configuration' => [ 
                'bucket' => 'your-bucket-name', // can be overriden with \Yii::$app->params['s3bucket']
                'version' => 'latest',
                'region' => 'your-bucket-region', // can be overriden with \Yii::$app->params['s3region']
                'scheme' => 'http',
            ],            
        ],
    ]
];

Be certain to check the widgets folder for exposed parameters.

Use

Standalone

Simply navigate to /s3manager

With a file input (active form)

In your form, add the following (ie. views/post/form.php)

use skylineos\yii\s3manager\widgets\{FileInput, MediaManagerModal};

Wherever you want your form field:

<label>My Field</label>
<?= FileInput::widget(['model' => $model, 'attribute' => 'myField']) ?>

Then, at the bottom of the page (after your <?php ActiveForm::end(); ?>) <?= MediaManagerModal::widget(['s3region' => 'us-east1', 's3bucket' => 'my-bucket-name']) ?>

With TinyMCE

On your form.php

use skylineos\yii\s3manager\widgets\{TinyMce, MediaManagerModal};

Wherever you want your TinyMCE (client options are largely up to you):

<?= $form->field($model, 'content')->widget(TinyMce::className(), [
    'options' => ['rows' => 15],
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste image"
        ],
        'menubar' => 'edit insert view format table tools help',
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    ]
]);?>

Then, at the bottom of the page (after your <?php ActiveForm::end(); ?>) <?= MediaManagerModal::widget(['s3region' => 'us-east1', 's3bucket' => 'my-bucket-name']) ?>