定制 exoodev/yii2-storage 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

exoodev/yii2-storage

Composer 安装命令:

composer require exoodev/yii2-storage

包简介

The Storage extension for the Yii2 framework

README 文档

README

Example application configuration:

'components' => [
    'fileStorage' => [
        'class' => 'exoo\storage\FileStorage',
        'storage' => [
            'class' => 'yii2tech\filestorage\local\Storage',
            'basePath' => '@storage',
            'dirPermission' => 0775,
            'filePermission' => 0755,
            'buckets' => [
                'files' => [
                    'baseSubPath' => '_files',
                    'fileSubDirTemplate' => '{ext}/{^name}/{^^name}',
                ],
                'images' => [
                    'baseSubPath' => '_images',
                    'fileSubDirTemplate' => '{^name}/{^^name}/{^^^name}',
                ],
            ]
        ],
        'actions' => [
            'storage' => [
                'file' => [
                    'bucketName' => 'files',
                    'sortable' => true,
                ],
                'image' => [
                    'bucketName' => 'images',
                    'sortable' => true,
                    'transformImage' => [
                        'thumbnail' => [
                            'large' => ['width' => 1000, 'height' => null],
                            'medium' => ['width' => 300, 'height' => null],
                            'small' => ['width' => 150, 'height' => null],
                        ],
                    ],
                ],
            ],
        ],
    ]
]

Example controller configuration:

public function actions()
{
    return [
        'file' => [
            'class' => 'exoo\storage\actions\FileAction',
            'modelClass' => 'exoo\shop\models\Product',
            'bucketName' => 'shop',
        ],
        'image' => [
            'class' => 'exoo\storage\actions\FileAction',
            'modelClass' => 'exoo\shop\models\Product',
            'bucketName' => 'shop',
            'transformImage' => [
                'thumbnail' => [
                    'medium' => [
                        'width' => 250,
                        'height' => 250,
                    ],
                    'small' => [
                        'width' => 100,
                        'height' => 100,
                    ],
                ],
                'watermark' => [
                    'watermarkImage' => '@web/images/logo/watermark_logo.png',
                    'start' => [100, 100],
                    'thumbnail' => 'medium'
                ]
            ],
            'relation' => 'images',
            'relationAttribute' => 'product_id',
            'sortable' => true,
        ],
    ];
}

Example behavior configuration for model:

public function behaviors()
{
    return [
        'file' => [
            'class' => FileBehavior::className(),
            'relation' => 'images',
            'relationAttribute' => 'category_id',
            'bucketName' => 'shop',
            'transformImage' => [
                'thumbnail' => [
                    'medium' => [
                        'width' => 250,
                        'height' => 250,
                    ],
                    'small' => [
                        'width' => 100,
                        'height' => 100,
                    ],
                ],
                'watermark' => [
                    'watermarkImage' => '@web/images/logo/watermark_logo.png',
                    'start' => [100, 100],
                    'thumbnail' => 'medium'
                ]
            ],
        ]
    ];
}

Example widget configuration:

use exoo\widgets\FileInput;

<?= $form->field($post, 'filename')->widget(FileInput::className(), [
    'url' => ['image'],
    'sortable' => true,
    'clientOptions' => [
        'mime' => 'image/*',
        'cropperOptions' => [
            'aspectRatio' => 16 / 9
        ]
    ]
]) ?>

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固