1

I am using codeigniter for a project. I need to use azure storage. So I have used composer to get the microsoft azure php libraries. I am trying to list the buckets in a model file. I type

use WindowsAzure\Common\ServicesBuilder;

int that file. On execution, it crashes at this line. Is it a path problem. Can someone help? I also tried puting the require "vendor/autoload.php" file. It didn't help. What can I do to make it work?

Ratan Senapathy
  • 2,148
  • 2
  • 10
  • 14
  • Did you get any error? – Aaron Chen Jul 26 '17 at 06:00
  • You can follow [this step by step](https://stackoverflow.com/questions/38813987/integrating-mailjet-api-v3-wrapper-as-codeigniter-library/38815612#38815612) for installing your library of choice with composer. Check that example there. – Tpojka Jul 26 '17 at 23:07

1 Answers1

1

As you are using composer, you can install CodeIgniter with one command. See CodeIgniter Composer Installer for details.

composer create-project kenjis/codeigniter-composer-installer codeigniter

Then cd into your ci project path and install Azure SDK for PHP by running the command:

composer require microsoft/windowsazure

After these done, you can use the following code to work with Azure storage in the controller.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

use WindowsAzure\Common\ServicesBuilder;

class Welcome extends CI_Controller {

    public function index()
    {
        $account = 'yourAccoutName';
        $key = 'yourAccessKey';
        $connectionString = "DefaultEndpointsProtocol=http;AccountName=$account;AccountKey=$key";
        $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
        // ...

        $this->load->view('welcome_message');
    }
}
Aaron Chen
  • 9,835
  • 1
  • 16
  • 28