emimontesdeoca / pimcore-bundle-azure-blob-sync
此插件用于将 Pimcore 中的所有记录资产同步到 Azure Blob 存储中
v1.3
2020-07-28 14:22 UTC
Requires
- php: >=5.3.0
- microsoft/azure-storage-blob: ^1.5
This package is auto-updated.
Last update: 2024-09-26 15:30:06 UTC
README
Pimcore Azure Bundle 用于将 Pimcore 资产推送到 Microsoft Azure Blob 存储中
兼容 Pimcore > v5.6。已在 Pimcore 6 上测试
安装
使用 Composer 安装
composer require rohitrajv5/pimcore-bundle-azure-blob-sync
执行以下命令
bin/console pimcore:bundle:enable AzurePimcoreBundle bin/console assets:install web
插件外观如下
Pimcore 管理员中的更改
-
转到 Pimcore 管理员 -> 设置 -> Azure Blob 容器设置
-
输入您的凭据并保存。
配置与设置
在 "app/constant.php" 中添加以下代码
try { $file = __DIR__ . '/../var/config/azure.php'; if (file_exists($file)) { $azureConfig = include($file); } } catch (\Exception $e) { $azureConfig = []; } $azureEnabled = FALSE; if (isset($azureConfig['enableAzure']) && $azureConfig['enableAzure']) { $azureEnabled = TRUE; define("AZURE_ACCOUNT_URL", $azureConfig['accountUrl']); define("AZURE_ACCOUNT_NAME", $azureConfig['accountName']); define("AZURE_ACCOUNT_KEY", $azureConfig['accountKey']); define("AZURE_CONTAINER", $azureConfig['container']); $azureFileWrapperPrefix = "blob://" . AZURE_CONTAINER; // do NOT change define("PIMCORE_ASSET_DIRECTORY", $azureFileWrapperPrefix . "/assets"); //define("PIMCORE_TEMPORARY_DIRECTORY", $azureFileWrapperPrefix . "/tmp"); //constants for reference in the views //define("PIMCORE_TRANSFORMED_ASSET_URL", AZURE_ACCOUNT_URL . "/" . AZURE_CONTAINER . "/assets"); // the following paths should be private! define("PIMCORE_VERSION_DIRECTORY", $azureFileWrapperPrefix . "/versions"); //define("PIMCORE_RECYCLEBIN_DIRECTORY", $azureFileWrapperPrefix . "/recyclebin"); //define("PIMCORE_LOG_MAIL_PERMANENT", $azureFileWrapperPrefix . "/email"); //define("PIMCORE_LOG_FILEOBJECT_DIRECTORY", $azureFileWrapperPrefix . "/fileobjects"); } define("ENABLE_AZURE",$azureEnabled);
取消注释您想要在 Azure Blob 存储上同步的选项。
在 "app/startup.php" 中添加以下代码常量
use AzurePimcoreBundle\AzureBlobStorage\StreamWrapper; if (ENABLE_AZURE) { $accountUrl = AZURE_ACCOUNT_URL; $accountName = AZURE_ACCOUNT_NAME; $accountKey = AZURE_ACCOUNT_KEY; $connectionString = "DefaultEndpointsProtocol=https;AccountName=" . $accountName . ";AccountKey=" . $accountKey; $container = AZURE_CONTAINER; $blobClient = \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobService($connectionString); StreamWrapper::register($blobClient, 'blob'); \Pimcore\File::setContext(stream_context_create([ 'blob' => ['seekable' => true] ])); }
许可证
GPL-3.0+