We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Public Cloud API PHP example please


ktwalrus
2016-04-13, 03:25 PM
I just signed up for Public Cloud and haven't used Object Storage from PHP yet, but I think it is easy enough to do if you use Rackspace's php-opencloud SDK.

Here is a link to the documentation: http://docs.php-opencloud.com/en/latest/. It looks like OVH Public Cloud uses Identity v2 API for authentication and Object Store v1 for access to containers and objects. The Rackspace documentation has examples throughout.

I just tried a small example and found that the default catalog names in the php-opencloud SDK are not the same as the catalog names OVH uses. OVH seems to use these service names:
  • "nova" for Compute endpoint
  • "neutron" for Network endpoint
  • "cinderv2" for Volumev2 endpoint
  • "glance" for Image endpoint
  • "cinder" for Volume endpoint
  • "swift" for Object Store endpoint
  • "keystone" for Identity endpoint


Note I installed php-opencloud SDK in the directory '/openstack' on my server.

Here is my quick test:

PHP Code:
require '/openstack/vendor/autoload.php';

use 
OpenCloud\OpenStack;

// Needed to add a user in the OpenStack section of the OVH Public Cloud Control Panel
// and use the values in the downloaded openrc.sh file for the username, password, and tenantId.

$client = new OpenStack('https://auth.cloud.ovh.net/v2.0/', array(
  
'username' => 'XXXXXXXXX',
  
'password' => 'XXXXXXXXXXXXXXX',
  
'tenantId' => 'XXXXXXXXX',
));

$objectStoreService $client->objectStoreService('swift''BHS1');

$containers $objectStoreService->listContainers();
foreach (
$containers as $container) {
    
/** @var $container OpenCloud\ObjectStore\Resource\Container **/
    
print($container->name."\n");
}

maxlogov
2016-03-28, 08:48 AM
Hi,
I am trying to solve very simple task, i need to move image files from dedicated server to Public Cloud Object Store with use of PHP.
I need very simple example of PHP - Upload File, Create Container, Remove file.
Very easy, went thru tons of docs and still did not figure out how to do that.
Please post any examples , thank you.