, (*1)
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., (*2)
For license information check the LICENSE-file., (*3)
Installation
The preferred way to install this extension is through composer., (*4)
Either run, (*5)
php composer.phar require --prefer-dist skylineos/yii2-s3manager
or add, (*6)
"skylineos/yii2-s3manager": "~3.0.0"
to the require section of your composer.json., (*7)
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., (*8)
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., (*9)
Use
Standalone
Simply navigate to /s3manager, (*10)
In your form, add the following (ie. views/post/form.php), (*11)
use skylineos\yii\s3manager\widgets\{FileInput, MediaManagerModal};
, (*12)
Wherever you want your form field:, (*13)
<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']) ?>
, (*14)
With TinyMCE
On your form.php, (*15)
use skylineos\yii\s3manager\widgets\{TinyMce, MediaManagerModal};
, (*16)
Wherever you want your TinyMCE (client options are largely up to you):, (*17)
<?= $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']) ?>
, (*18)