PHP code example of rohitrajv5 / pimcore-bundle-azure-blob-sync
1. Go to this page and download the library: Download rohitrajv5/pimcore-bundle-azure-blob-sync library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rohitrajv5 / pimcore-bundle-azure-blob-sync example snippets
try {
$file = __DIR__ . '/../var/config/azure.php';
if (file_exists($file)) {
$azureConfig = leAzure']) && $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);
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]
]));
}