]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
doc: Add Librados PHP documentation
authorWido den Hollander <wido@42on.com>
Fri, 9 Jan 2015 13:15:32 +0000 (14:15 +0100)
committerWido den Hollander <wido@42on.com>
Fri, 9 Jan 2015 13:16:08 +0000 (14:16 +0100)
doc/rados/api/librados-intro.rst

index c120ec9fe9072c722c39c7e5e9a4e8742b009424..82ea014cd7dd74db794633707a7a035d21b048b7 100644 (file)
@@ -119,6 +119,36 @@ To build the documentation, execute the following::
        ant docs
 
 
+Getting librados for PHP
+-------------------------
+
+To install the ``librados`` extension for PHP, you need to execute the following procedure:
+
+#. Install php-dev. For Debian/Ubuntu, execute::
+
+       sudo apt-get install php5-dev build-essential
+
+   For CentOS/RHEL, execute::
+
+       sudo yum install php-devel
+
+#. Clone the ``phprados`` repository::
+
+       git clone https://github.com/ceph/phprados.git
+
+#. Build ``phprados``::
+
+       cd phprados
+       phpize
+       ./configure
+       make
+       sudo make install
+
+#. Enable ``phprados`` in php.ini by adding::
+
+       extension=rados.so
+
+
 Step 2: Configuring a Cluster Handle
 ====================================
 
@@ -456,6 +486,28 @@ to specify the classpath. For example::
        java CephClient
 
 
+PHP Example
+------------
+
+With the RADOS extension enabled in PHP you can start creating a new cluster handle very easily:
+
+.. code-block:: php
+
+       <?php
+
+       $r = rados_create();
+       rados_conf_read_file($r, '/etc/ceph/ceph.conf');
+       if (!rados_connect($r)) {
+               echo "Failed to connect to Ceph cluster";
+       } else {
+               echo "Successfully connected to Ceph cluster";
+       }
+
+
+Save this as rados.php and run the code::
+       php rados.php
+
+
 Step 3: Creating an I/O Context
 ===============================
 
@@ -875,6 +927,16 @@ Java-Example
        }
 
 
+PHP Example
+-----------
+
+.. code-block: php
+
+       $io = rados_ioctx_create($r, "mypool");
+       rados_write_full($io, "oidOne", "mycontents");
+       rados_remove("oidOne");
+       rados_ioctx_destroy($io);
+
 
 Step 4: Closing Sessions
 ========================
@@ -913,7 +975,12 @@ Python Example
        print "Shutting down the handle."
        cluster.shutdown()
 
+PHP Example
+-----------
+
+.. code-block:: php
 
+       rados_shutdown($r);