Jeroen Moors

Jeroen Moors

independent operations manager

phprados

phprados is a php extension written in C to connect to the Ceph storage cluster.

It was initially written by Wido Den Hollander, providing a procedural interface. I’ve extended this library with a very easy to use OO-interface.

To write data to your Ceph cluster use:

<?php
    // Adapt with your cluster settings
    $mon_host = "172.16.0.2";
    $key      = "__YOUR_KEY_GOES_HERE__";
    $pool     = "mycluster";

    // Create a new objectn";
    $rados = new Rados();

    // Connect to the cluster
    $rados->connect($mon_host, $key, $pool);
    
    // Read a local file
    $data = file_get_contents("/tmp/some_image.jpg");
    
    // Write the data to the cluster, using 'my-image-id' as its unique key
    $rados->write("my-image-id", $data);

To retrieve data from the Ceph cluster use:

<?php
    // Adapt with your cluster settings
    $mon_host = "172.16.0.2";
    $key      = "__YOUR_KEY_GOES_HERE__";
    $pool     = "mycluster";

    // Create a new objectn";
    $rados = new Rados();
    
    // Connect to the cluster
    $rados->connect($mon_host, $key, $pool);

    // Read the data from the cluster
    $data = $rados->read("my-image-id");

    // Set the right header for image output
    header("Content-type: image/jpg");
    
    // print the data to the client
    print $data

The goal of the OO-interface is to provide the easiest possible interface to a Ceph cluster.