bongo/bongo-s3asset-installer-bundle

此包可以将您的 symfony 网站应用程序的资产轻松上传到 Amazon S3。

安装: 47

依赖: 0

建议: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.8 2019-02-17 16:47 UTC

This package is auto-updated.

Last update: 2024-09-12 05:11:36 UTC


README

#Symfony S3 Asset Installer

此包添加了一个控制台命令,以便在本地文件系统与 Amazon S3 之间同步资产。使用此包的好处是,它不会在 S3 存储桶中创建丑陋的键,并允许您隔离生产环境和开发环境的资产。

安装非常简单。首先使用 composer 安装此包。

安装

在您的 composer.json 中要求此包

composer require bongo/bongo-s3asset-installer-bundle

然后在您的 Appkernel 中启用它

public function registerBundles()
{
    $bundles = [
        ....
        new Bongo\S3AssetInstallerBundle\BongoS3AssetInstallerBundle(),
    ]
}

配置

您必须提供以下参数

amazon_s3_key: (your key)
amazon_s3_secret: (your secret)
amazon_s3_region:  (your region)
amazon_s3_bucket: (your bucket name without s3://)

然后在您的 config.yml 中添加以下配置

bongo_s3_asset_installer:
    amazon_s3_key: "%amazon_s3_key%"
    amazon_s3_secret: "%amazon_s3_secret%"
    amazon_s3_region: "%amazon_s3_region%"
    amazon_s3_bucket: "%amazon_s3_bucket%"

在 config_prod.yml 中添加 assets_base_url

framework:    
    assets:
        base_urls:
            - 'http://cdn.production.com/'

在 config_dev.yml 中添加 assets_base_url

framework:    
    assets:
        base_urls:
            - 'http://local.localhost.com/'

此外,您还需要将 write_to 参数更改为您的 S3 存储桶

assetic:
    write_to: s3://my_bucket

使用方法

只需使用正常的资产命令,但使用 S3 作为目标

首先安装资产

php app/console s3:assets:install s3://my-bucket/

或者

php bin/console s3:assets:install s3://my-bucket/

在资产安装后,导出资产

php app/console assetic:dump s3://my-bucket

或者

php bin/console assetic:dump s3://my-bucket