Resources



Sample Code and Libraries

PHP Library for Amazon SimpleDB

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
Average Review:

PHP Library for Amazon SimpleDB

Submitted By: Elena@AWS  
AWS Products Used: Amazon SimpleDB
Language(s): PHP
License: Apache License 2.0

About this Library

  • Based on the 2009-04-15 API version.

What's New?

  • 2009-05-20: Deprecate Query and QueryWithAttributes. Please migrate to Select API
  • 2009-03-23: Support for BatchPutAttributes
  • 2009-01-26: Fix missing parenthesis error ("unexpected T_STRING")
  • 2008-12-24: Fix notice output (no side effects, just noise)
  • 2008-12-23:Url encoding fix (some calls with signature version 2 were affected)
  • 2008-12-17: Support for signature version 2, DomainMetadata and Select API, https endpoint
  • 2008-08-28: Support for new API - QueryWithAttributes
  • 2008-07-23: Fixed signature-related sort issue, support for .config.inc.php configuration for all samples

Prerequisites

Package Content

Directory Overview
src Source distribution of library.

Quick Start

Library comes with code samples for each available service API. To get started with the library, follow these steps:
  1. Extract the amazon-simpledb-2009-04-15-php5-library.zip file into a working directory.
  2. Go to src/Amazon/SimpleDB/Samples subdirectopry
  3. Edit .config.inc.php:


    • Set AWS Access Key ID and AWS Secret Access Key
    • 
          define('AWS_ACCESS_KEY_ID', '<Your Access Key ID>');
          define('AWS_SECRET_ACCESS_KEY', '<Your Secret Access Key>');
                      


    • Open CreateDomainSample.php sample, and find part:
    •  // @TODO: set request. Action can be passed as Amazon_SimpleDB_Model_CreateDomainRequest
       // object or array of parameters
       // invokeCreateDomain($service, $request);
                      


    • And set DomainName parameter:
    •  invokeCreateDomain($service, array('DomainName' => 'MyDomain'));
                      

  4. Run CreateDomain sample:
  5.    php CreateDomainSample.php
                
  6. You should see the output similar to the following:


  7.     CreateDomainResponse
            ResponseMetadata
                RequestId
                    95cdcb68-f46c-400b-8265-8c2de2a5c475
                

  8. Experiment with samples. When ready, install library to your php include path and use it

Happy coding!

Previous Version Download

Making Requests to a Different Region

To make the service call to a different region, instantiate the client with the configuration object, and pass the region-specific endpoint. For example:

$service = new Amazon_SimpleDB_Client
    (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, 
    array('ServiceURL' => 'https://sdb.eu-west-1.amazonaws.com'));

See the Amazon SimpleDB Developer Guide for a complete list of region endpoints.

Comments, Questions or Feedback

If you have any comments, questions or feedback on the library, please start discussion here.

Discussion

The 5 most recent discussion messages. View full discussion.

J. DEBORD
RealName(TM)
Posts: 1
Registered: 1/25/09
Re: PHP Library for Amazon SimpleDB
Posted: Jan 26, 2009 12:00 AM PST   in response to: Thomas Myer
 
  Click to reply to this thread Reply

/**
 *  PHP Version 5
 *
 *  @category    Amazon
 *  @package     Amazon_SimpleDB
 *  @copyright   Copyright 2008 Amazon Technologies, Inc.
 *  @link        http://aws.amazon.com
 *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
 *  @version     2007-11-07
 */

There is a ) missing on line 667 of Client.php . Why hasn't this been corrected?

Parse error
: syntax error, unexpected ';' in /home/XXXXX/subdomains/lab/include/Amazon/SimpleDB/Client.php on line 667


Elena@AWS
Posts: 155
Registered: 2/9/06
Re: PHP Library for Amazon SimpleDB
Posted: Jan 26, 2009 1:10 PM PST   in response to: J. DEBORD
 
  Click to reply to this thread Reply

Missing parenthesis issue is corrected. Updated version of the library can be downloaded here:

http://developer.amazonwebservices.com/connect/entry.jspa?categoryID=148&externalID=1135


Thanks!
-elena






Elena@AWS
Posts: 155
Registered: 2/9/06
Re: PHP Library for Amazon SimpleDB
Posted: Jan 26, 2009 1:17 PM PST   in response to: daveh60
 
  Click to reply to this thread Reply

You can pass the ServiceURL parameter to override the default host:

new Amazon_SimpleDB_Client ("accesskeyid", "secretkey", array("ServiceURL" => "http://192.168.1.1"));
 

-elena


Gandalf
Posts: 28
Registered: 2/9/08
Re: PHP Library for Amazon SimpleDB
Posted: May 27, 2009 7:49 AM PDT   in response to: Elena@AWS
 
  Click to reply to this thread Reply

I think there is an error in the documentation for PutAttributesSample.php

$request = new Amazon_SimpleDB_Model_PutAttributes();

should be

$request = new Amazon_SimpleDB_Model_PutAttributesRequest();


strmartin
Posts: 3
Registered: 7/4/08
Re: PHP Library for Amazon SimpleDB
Posted: Jul 1, 2009 8:47 AM PDT   in response to: Thomas Myer
 
  Click to reply to this thread Reply

Doesn't your Amazon_SimpleDB_Model_SelectRequest support NextToken handling?
How would you fetch more than 100 rows with your lib?

Regards!



Reviews
Create Review Write a Review

Neither Simple Nor Functional, May 23, 2009 9:27 AM
Reviewer: Gandalf
This library sucks. There are four levels of folders and a myriad of include files that don't work. I even tried hard-coding the include paths. There is a "Mock" version and a live version but neither is enabled without code changes to TEN different files to test all the samples. In the spirit of "Simple" there should be a lightweight PHP library with understandable methods or even just functions that gets the job done.

Examples running out of the box, Aug 9, 2009 10:41 PM
Reviewer: starmerf
My experience was quite different. I downloaded the PHP Library for Amazon SimpleDB and modified .config... and CreateDomainSample.php. The example failed with the error message Class 'DOMDocument' not found A quick google search on the error message revealed that I should check to see if php-xml was installed. Once installed (Fedora 11, yum install php-xml) the example provided the correct output

Overcomplicated and poorly documented, Dec 29, 2009 6:00 AM
Reviewer: sam28111
It works, but it's not great, and really takes the 'Simple' out of SimpleDB.
Welcome, Guest Help
Login Login