"PHP SDK for Openstack/rackspace APIs" uses object storage services
Swift is an object storage service for OpenStack. In the Php-opencloud library, the ObjectStore class (OpenStack or Rackspace) created by the Connection object is accessed.
For example:
$cloud = new \OpenCloud\OpenStack(array( 'username'=>'{username}','password'=>'{password}'));$swift = $cloud->ObjectStore('cloudFiles','DFW');
With the newly created $swift, you can use different object storage components.
The highest-level object storage component instance is Container,container is the collection name of the object, similar to the directory and folder in the file system (not actually equivalent).
All objects are saved in the container.
Enumerating all container in an object storage instance
The Containerlist object is a collection of container objects. Enumerate all container in an object storage instance:
$containers = $swift->ContainerList();while($container = $containers->Next()) printf("%s\n", $container->name);
Just like other object collections, this also supports the first (), Next (), and size () methods.
Create a new container
Create a new (empty) container using the container () method of the newly created $swift object above.
$mycontainer = $swift->Container();
Save the container to the object storage instance, using the Create () method:
$mycontainer->Create('MyContainerName');
Name is not required in the Create () method, if name is already set. It is also convenient to specify the name directly in the method.
$mycontainer->name = 'MyContainerName';$mycontainer->Create();
retrieving a container that already exists
If you pass a parameter to the container () method of the ObjectStore object, you can retrieve an existing container:
$oldcontainer = $swift->Container('SomeOldContainer');
In this case, information about Someoldcontainer will be retrieved. This contains the metadata information for the container.
printf("Container %s has %d object(s) consuming %d bytes\n", $oldcontainer->name, $oldcontainer->count, $oldcontainer->bytes);
Delete Container
Delete () method remove container
$oldcontainer->Delete();
Note that container must be empty when it is deleted, that is, there must be no object associated with it.
Update container
In the background, the container is created and updated exactly the same way. You can use the Create () method to update the container; However, the update () method is also present as an alias to the Create () method because it may be different in semantics (in your program):
$oldcontainer->metadata->update_time = time();$oldcontainer->Update();
Translated from: https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/objectstore.md