This PHP sample application demonstrates how to make a good use of modules provided by Microsoft Azure blob storage SDK. Microsoft Azure Storage SDK for PHP resource code can be found on Azure GitHub repository.
For now, the Azure Storage SDK for PHP shares almost the same interface as the storage blobs, tables and queues APIs in Azure SDK for PHP. However, there are some minor breaking changes that need to be addressed during your migration.
This code sample is separated into two tiers. The frontend is built using AngularJs. The AngularJs source code scripts are in src folder, and are combined with br gulp. The backend is built using PHP, implementing with Azure storage SDK for PHP. All the operations on Azure blob storage in the frontend are called via $http module, which is against the functions in PHP backend.
All the functions that are called via frontend are listed in this single script as trial.php. The function first parses the URL param key to determine which kind of resources the client end is requesting, creating/initializing or trailing the code sample.
If the URL params have the key "init", it means the client end is asking for initializing the code sample.
Switch the param value in following cases:
Before running this code sample, please open settings.php in the api directory.
Here we need the storage account name and access key for setting up a correct configuration. To get your storage account and access key, please login Azure Manage Portal, click the STORAGE on the left navigation bar, select your storage account on the right side list, click the Manage Access Keys button at the bottom bar.
Make sure your PHP runtime has enabled the extension "fileinfo". You can use "phpinfo()" function in PHP script or run command "php -m" in cmdlet to check whether your PHP runtime has enabled this extension.
(Optional) You can use WebMatrix to work with this PHP sample. WebMatrix is a free and light-weight tool that will let you create web sites using various technologies like PHP, Asp.Net, Node.js etc. In order to run this sample in Web matrix, you can choose "Open Site", then choose "Folder as Site" and select the folder that contains all the downloaded files.
(Optional) You can use PHP Build-in web server for a quick local test. Use following command in cmdlet from the code sample directory:
php -S localhost:8000
Click 3 Create buttons in the home page to create the container and blobs resources in your Azure storage. The result of operations will be directly output in the block under the buttons:
Click the trial button on the top navigation bar to start the trail of the code sample.
Then it will redirect to the page that shows the container info.
Enter the container, redirect the page that shows the blob list separated by delimiter /, which can be treated as a virtual directory.
Enter the virtual directory of text blobs lists.
Click the horizontal spots button to get paginated blobs. Click the vertical spots button to show the details of the blob.
Click the disk-like button to get the content of the text blob.
Back to the root of the container, enter the video blobs virtual directory to trail the video blobs.
Azure Storage SDK for PHP: https://github.com/Azure/azure-storage-php
Microsoft Azure storage documents: https://azure.microsoft.com/en-us/documentation/services/storage
|JSON, REST, PHP, AngularJs||REST, Microsoft Azure SDK for PHP, AngularJs||Web, Cloud, Storage|| ||en-US||6/28/2016||MIT|