limit0/assets-bundle

为使用limit0/assets的项目实现图像上传支持

安装: 254

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

开放问题: 0

类型:symfony-bundle

v1.0 2017-03-07 18:01 UTC

This package is not auto-updated.

Last update: 2024-09-15 01:57:35 UTC


README

为使用limit0/assets的项目实现图像上传支持

要求

  • 您需要一个AWS账户,并能够访问S3存储桶,或者
  • 您需要通过您的Web服务器用户对本地存储路径具有写入权限。

安装

通过composer安装此包

composer require limit0/assets-bundle

在您的AppKernel.php中包含此bundle

    public function registerBundles()
    {
        $bundles = [
            // ...
            new Limit0\AssetsBundle\Limit0AssetsBundle(),
            // ...

配置

使用您首选的资产存储提供商配置此bundle。完整的可能配置如下所示

limit0_assets:
    engine: aws_s3                              # Either `aws_s3` or `local_storage`
    http_prefix: //my-cdn.io/path-to-images/    # A URL prefix for your uploaded images. Can be relative.
    # The URL provided by the uploader will prefix the filename with this path, so they can be viewed.
    aws_s3:
        region: us-east-1                       # Default S3 storage region
        acl: public-read                        # Default ACL for uploaded files
        bucket: mybucket                        # Bucket to upload files to
    local_storage:
        path: /uploads/myproject                # Path on server to upload files to. Can be relative.

如果使用AWS S3,则需要bucket。如果使用本地存储,则需要path

路由

您需要导入此bundle的路由。为了防止任何潜在的冲突问题,确保在加载其他应用程序路由之前加载它

limit0_assets:
    resource: "@Limit0AssetsBundle/Resources/config/routing.yml"
    prefix:   /

app_bundle:
    resource: "@AppBundle/Resources/config/routing.yml"
# ...