• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

PHP Cloud Files API Installation


Contents

Overview

This tutorial will cover how to install the PHP API on your machine. We assume you have PHP installed on your local machine. Either with Apache or without. For more help installing PHP please take a look at php.net. We will cover both Windows and *nix installs (should be the same for OSX).

Note: The PHP bindings described here are no longer being developed by Rackspace.  The newer PHP SDK is described on our API documentation site.

What we need

Windows Install

  • Head to our Rackerlabs Github.
  • Select Download I recommend downloading it as a Zip.
  • Save the Zip to your Desktop.
  • Now go ahead and unpack the zip on your desktop
  • You should have a folder that is named something like this: rackspace-php-cloudfiles-22fbbe643e20165f6307bf515c32106d74183de8
  • Drill down one Level and you should see 3 files cloudfiles.php cloudfiles_http.php and cloudfiles_exceptions.php
  • Copy these folders into your universal include folder for my install it was C:\php5\pear ( I also had to create the php5 and pear folders)

*Nix Install

  • Head to our Rackerlabs Github.
  • Select Download I recommend downloading it as a .tar.gz.
  • Save the tarball to your Desktop.
  • Open your terminal
  • Run this command from your terminal:
tar zxvf ~/Desktop/rackspace-php-cloudfiles-22fbbe643e20165f6307bf515c32106d74183de8.tar.gz

You may need to change the filename to reflect your copy of the API

  • You should have a folder that is named something like this: rackspace-php-cloudfiles-22fbbe643e20165f6307bf515c32106d74183de8
  • Go Ahead and cd into the directory using this command:
cd ~/Desktop/rackspace-php-cloudfiles-22fbbe643e20165f6307bf515c32106d74183de8

Remember you might have to change the folder name to reflect your own copy of the API

  • Now that we are in the right directory lets get the files to the right place run this command from terminal:

For RedHat based distros

su

Enter your root password Then

mv cloudfiles* /usr/share/php/

Check our work

Now lets make sure we have everything setup ok.

  • Open your favorite text editor
  • Type this code:
<?php
  require('cloudfiles.php');
?>
  • Save the file on your desktop as cfcheck.php
  • Open command prompt or terminal and cd to your desktop
  • Run this command from the prompt or terminal:
php cfcheck.php

If you are returned to the prompt with no errors the PHP API is installed

If you get an error like this:

PHP Fatal error:  require(): Failed opening required 'cloudfiles.php' 
(include_path='.;C:\php5\pear') in C:\Documents and Settings\jimbob\Desktop\cfcheck.php on line 1

Then you do not have the files located in the right place. This error should print out the include_path so make sure you have the files located there. Or you can change the include path in the php.ini but that is beyond the scope of this tutorial. If you have anymore questions please shoot an email to cloudfiles@rackspacecloud.com.



© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER

5 Comments

I get a error on command prompt "php" is not recognized as an internal or external operable command or batch file

It sounds like you either need to install PHP or you need to add the PHP executable's location to your PATH environment variable.

Composer.json was just added to the master repo for php-cloudfiles https://github.com/rackspace/php-cloudfiles/blob/master/composer.json. It wold be great to if you submit the package to https://packagist.org/,

thank you!!

It seems like this functionality is moving, but the old files can be found at https://github.com/rackerlabs/php-cloudfiles .

Thanks Toby. I'll get the link in the article updated. The newer, in-development package is our PHP SDK:

http://docs.rackspace.com/sdks/guide/content/php.html

Add new comment