From ba00033e4f5ecc0811f7fc5512714a3508cf4dff Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 15 Mar 2012 09:18:35 -0500 Subject: [PATCH] Updating the markdown. --- ...orial-example.php => oo-tutorial-code.php} | 0 doc/{tutorial.mdown => oo-tutorial.md} | 48 +++++++++++-------- .../Storage/ObjectStorage/Container.php | 9 +++- 3 files changed, 35 insertions(+), 22 deletions(-) rename doc/{tutorial-example.php => oo-tutorial-code.php} (100%) rename doc/{tutorial.mdown => oo-tutorial.md} (92%) diff --git a/doc/tutorial-example.php b/doc/oo-tutorial-code.php similarity index 100% rename from doc/tutorial-example.php rename to doc/oo-tutorial-code.php diff --git a/doc/tutorial.mdown b/doc/oo-tutorial.md similarity index 92% rename from doc/tutorial.mdown rename to doc/oo-tutorial.md index a29a39e..0d001b2 100644 --- a/doc/tutorial.mdown +++ b/doc/oo-tutorial.md @@ -1,4 +1,5 @@ -# Using HPCloud-PHP +Using HPCloud-PHP {#oo-tutorial} +================= HPCloud-PHP provides PHP language bindings for the HPCloud APIs. HPCloud is an OpenStack-based cloud service offering a wide (and ever-expanding) @@ -9,6 +10,10 @@ tool that interacts with HP Cloud's Object Storage. The emphasis in this article is on getting started and learning the concepts, not building a polished product. +**This tutorial focuses on the object-oriented API.** The other way to +work with this library is through the stream wrapper. That topic is +covered in another tutorial. + ## Pre-flight Check HPCloud-PHP has been developed to require PHP 5.3 or later. You are @@ -471,29 +476,30 @@ In the example above, then, one network request is issued by `proxyObject()`, but another is initiated when `$object->content()` is called. +### The RemoteObject in a Nutshell -==== STOPPED +Instances of a `RemoteObject` offer the following features: -### About Method Naming Conventions +- Access to an object stored on the remote object storage +- A proxying mechanism for lazily loading objects +- Support for loading via CDN (advanced) +- A stream-based API for using stream and file-based PHP functions +- Automatic tempfile-based caching for large objects (using + `php://temp`). -Note that in the HPCloud PHP library, accessors are nouns -(`containers()`, `accountInfo()`) while mutators and other actions are verbal -(`createContainer`, `setName()`). Accessors generally do not begin with -`get`. +`RemoteObject` instances can be updated and then passed to +`Container::save()` to update the copy on the server, too. -### Is Object Storage a Remote File System? +## Summary -In many ways, Object Storage works like a file system. It is persistent -storage for self-contained bundles of data. That's pretty much the core -of a file system, too. And like a file system, object storage uses a -name as the main identifier for the data. That is, an object name plays -approximately the same role as a file name. +At this point we have created a very basic script that connects to +HPCloud and works with object storage. Clearly, this only scratches the +surface of what the HPCloud PHP library does. But hopefully this is +enough to get you started with the library. -But there is one big difference: Object Storage does not have -directories. It can *fake it* (the slash character is a legal part of a -file name, and Object Storage has some semantic sugar to help with -that). But really, `foo/bar/baz.txt` is, to object storage, just a big -long name; not a "directory path". - -This is not going to make a difference for our demo app here, but it is -something to keep in mind. +The entire library is well documented, and the documentation is +[available online](https://github.com/hpcloud). You can also build a +local copy by installing [doxygen](http://www.stack.nl/~dimitri/doxygen) +(if you haven't already) and running `make docs` in the root of the +HPCloud PHP project. This will place the generated documents in +`docs/api/html`. diff --git a/src/HPCloud/Storage/ObjectStorage/Container.php b/src/HPCloud/Storage/ObjectStorage/Container.php index a5a4068..d541062 100644 --- a/src/HPCloud/Storage/ObjectStorage/Container.php +++ b/src/HPCloud/Storage/ObjectStorage/Container.php @@ -745,7 +745,7 @@ class Container implements \Countable, \IteratorAggregate { * @retval \HPCloud\Storage\ObjectStorage\RemoteObject * A remote object ready for use. */ - public function remoteObject($name) { + public function proxyObject($name) { $url = self::objectUrl($this->url, $name); $cdn = self::objectUrl($this->cdnUrl, $name); $headers = array( @@ -776,6 +776,13 @@ class Container implements \Countable, \IteratorAggregate { return $obj; } + /** + * This has been replaced with proxyObject(). + * @deprecated + */ + public function remoteObject($name) { + $this->proxyObject($name); + } /** * Get a list of objects in this container.