| 1 |
lars |
1 |
# AWS SDK for PHP
|
|
|
2 |
|
|
|
3 |
The AWS SDK for PHP enables developers to build solutions for Amazon Simple Storage Service (Amazon S3),
|
|
|
4 |
Amazon Elastic Compute Cloud (Amazon EC2), Amazon SimpleDB, and more. With the AWS SDK for PHP, developers
|
|
|
5 |
can get started in minutes with a single, downloadable package.
|
|
|
6 |
|
|
|
7 |
The SDK features:
|
|
|
8 |
|
|
|
9 |
* **AWS PHP Libraries:** Build PHP applications on top of APIs that take the complexity out of coding directly
|
|
|
10 |
against a web service interface. The toolkit provides APIs that hide much of the lower-level implementation.
|
|
|
11 |
* **Code Samples:** Practical examples for how to use the toolkit to build applications.
|
|
|
12 |
* **Documentation:** Complete SDK reference documentation with samples demonstrating how to use the SDK.
|
|
|
13 |
* **PEAR package:** The ability to install the AWS SDK for PHP as a PEAR package.
|
|
|
14 |
* **SDK Compatibility Test:** Includes both an HTML-based and a CLI-based SDK Compatibility Test that you can
|
|
|
15 |
run on your server to determine whether or not your PHP environment meets the minimum requirements.
|
|
|
16 |
|
|
|
17 |
For more information about the AWS SDK for PHP, including a complete list of supported services, see
|
|
|
18 |
[aws.amazon.com/sdkforphp](http://aws.amazon.com/sdkforphp).
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
## Signing up for Amazon Web Services
|
|
|
22 |
|
|
|
23 |
Before you can begin, you must sign up for each service you want to use.
|
|
|
24 |
|
|
|
25 |
To sign up for a service:
|
|
|
26 |
|
|
|
27 |
* Go to the home page for the service. You can find a list of services on
|
|
|
28 |
[aws.amazon.com/products](http://aws.amazon.com/products).
|
|
|
29 |
* Click the Sign Up button on the top right corner of the page. If you don't already have an AWS account, you
|
|
|
30 |
are prompted to create one as part of the sign up process.
|
|
|
31 |
* Follow the on-screen instructions.
|
|
|
32 |
* AWS sends you a confirmation e-mail after the sign-up process is complete. At any time, you can view your
|
|
|
33 |
current account activity and manage your account by going to [aws.amazon.com](http://aws.amazon.com) and
|
|
|
34 |
clicking "Your Account".
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
## Source
|
|
|
38 |
The source tree for includes the following files and directories:
|
|
|
39 |
|
|
|
40 |
* `_compatibility_test` -- Includes both an HTML-based and a CLI-based SDK Compatibility Test that you can
|
|
|
41 |
run on your server to determine whether or not your PHP environment meets the minimum requirements.
|
|
|
42 |
* `_docs` -- Informational documents, the contents of which should be fairly self-explanatory.
|
|
|
43 |
* `_samples` -- Code samples that you can run out of the box.
|
|
|
44 |
* `extensions` -- Extra code that can be used to enhance usage of the SDK, but isn't a service class or a
|
|
|
45 |
third-party library.
|
|
|
46 |
* `lib` -- Contains any third-party libraries that the SDK depends on. The licenses for these projects will
|
|
|
47 |
always be Apache 2.0-compatible.
|
|
|
48 |
* `services` -- Contains the service-specific classes that communicate with AWS. These classes are always
|
|
|
49 |
prefixed with `Amazon`.
|
|
|
50 |
* `utilities` -- Contains any utility-type methods that the SDK uses. Includes extensions to built-in PHP
|
|
|
51 |
classes, as well as new functionality that is entirely custom. These classes are always prefixed with `CF`.
|
|
|
52 |
* `README` -- The document you're reading right now.
|
|
|
53 |
* `config-sample.inc.php` -- A sample configuration file that should be filled out and renamed to `config.inc.php`.
|
|
|
54 |
* `sdk.class.php` -- The SDK loader that you would include in your projects. Contains the base functionality
|
|
|
55 |
that the rest of the SDK depends on.
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
## Minimum Requirements in a nutshell
|
|
|
59 |
|
|
|
60 |
* You are at least an intermediate-level PHP developer and have a basic understanding of object-oriented PHP.
|
|
|
61 |
* You have a valid AWS account, and you've already signed up for the services you want to use.
|
|
|
62 |
* The PHP interpreter, version 5.2 or newer. PHP 5.2.17 or 5.3.x is highly recommended for use with the AWS SDK for PHP.
|
|
|
63 |
* The cURL PHP extension (compiled with the [OpenSSL](http://openssl.org) libraries for HTTPS support).
|
|
|
64 |
* The ability to read from and write to the file system via [file_get_contents()](http://php.net/file_get_contents) and [file_put_contents()](http://php.net/file_put_contents).
|
|
|
65 |
|
|
|
66 |
If you're not sure whether your PHP environment meets these requirements, run the
|
|
|
67 |
[SDK Compatibility Test](http://github.com/amazonwebservices/aws-sdk-for-php/tree/master/_compatibility_test/) script
|
|
|
68 |
included in the SDK download.
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
## Installation
|
|
|
72 |
|
|
|
73 |
### Via GitHub
|
|
|
74 |
|
|
|
75 |
[Git](http://git-scm.com) is an extremely fast, efficient, distributed version control system ideal for the
|
|
|
76 |
collaborative development of software. [GitHub](http://github.com/amazonwebservices) is the best way to
|
|
|
77 |
collaborate with others. Fork, send pull requests and manage all your public and private git repositories.
|
|
|
78 |
We believe that GitHub is the ideal service for working collaboratively with the open source PHP community.
|
|
|
79 |
|
|
|
80 |
Git is primarily a command-line tool. GitHub provides instructions for installing Git on
|
|
|
81 |
[Mac OS X](http://help.github.com/mac-git-installation/), [Windows](http://help.github.com/win-git-installation/),
|
|
|
82 |
and [Linux](http://help.github.com/linux-git-installation/). If you're unfamiliar with Git, there are a variety
|
|
|
83 |
of resources on the net that will help you learn more:
|
|
|
84 |
|
|
|
85 |
* [Git Immersion](http://gitimmersion.com) is a guided tour that walks through the fundamentals of Git, inspired
|
|
|
86 |
by the premise that to know a thing is to do it.
|
|
|
87 |
* The [PeepCode screencast on Git](https://peepcode.com/products/git) ($12) will teach you how to install and
|
|
|
88 |
use Git. You'll learn how to create a repository, use branches, and work with remote repositories.
|
|
|
89 |
* [Git Reference](http://gitref.org) is meant to be a quick reference for learning and remembering the most
|
|
|
90 |
important and commonly used Git commands.
|
|
|
91 |
* [Git Ready](http://gitready.com) provides a collection of Git tips and tricks.
|
|
|
92 |
* If you want to dig even further, I've [bookmarked other Git references](http://pinboard.in/u:skyzyx/t:git).
|
|
|
93 |
|
|
|
94 |
If you're comfortable working with Git and/or GitHub, you can pull down the source code as follows:
|
|
|
95 |
|
|
|
96 |
git clone git://github.com/amazonwebservices/aws-sdk-for-php.git AWSSDKforPHP
|
|
|
97 |
cd ./AWSSDKforPHP
|
|
|
98 |
|
|
|
99 |
### Via PEAR
|
|
|
100 |
|
|
|
101 |
[PEAR](http://pear.php.net) stands for the _PHP Extension and Application Repository_ and is a framework and
|
|
|
102 |
distribution system for reusable PHP components. It is the PHP equivalent to package management software such as
|
|
|
103 |
[MacPorts](http://macports.org) and [Homebrew](https://github.com/mxcl/homebrew) for Mac OS X,
|
|
|
104 |
[Yum](http://fedoraproject.org/wiki/Tools/yum) and [Apt](http://wiki.debian.org/Apt) for GNU/Linux,
|
|
|
105 |
[RubyGems](http://rubygems.org) for Ruby, [Easy Install](http://packages.python.org/distribute/easy_install.html)
|
|
|
106 |
for Python, [Maven](http://maven.apache.org) for Java, and [NPM](http://npm.mape.me) for Node.js.
|
|
|
107 |
|
|
|
108 |
PEAR packages are very easy to install, and are available in your PHP environment path so that they are accessible
|
|
|
109 |
to any PHP project. PEAR packages are not specific to your project, but rather to the machine that they're
|
|
|
110 |
installed on.
|
|
|
111 |
|
|
|
112 |
From the command-line, you can install the SDK with PEAR as follows:
|
|
|
113 |
|
|
|
114 |
pear channel-discover pear.amazonwebservices.com
|
|
|
115 |
pear install aws/sdk
|
|
|
116 |
|
|
|
117 |
You may need to use `sudo` for the above commands. Once the SDK has been installed via PEAR, you can load it into
|
|
|
118 |
your project with:
|
|
|
119 |
|
|
|
120 |
require_once 'AWSSDKforPHP/sdk.class.php';
|
|
|
121 |
|
|
|
122 |
### Configuration
|
|
|
123 |
|
|
|
124 |
1. Copy the contents of [config-sample.inc.php](https://github.com/amazonwebservices/aws-sdk-for-php/raw/master/config-sample.inc.php)
|
|
|
125 |
and add your credentials as instructed in the file.
|
|
|
126 |
2. Move your file to `~/.aws/sdk/config.inc.php`.
|
|
|
127 |
3. Make sure that `getenv('HOME')` points to your user directory. If not you'll need to set
|
|
|
128 |
`putenv('HOME=<your-user-directory>')`.
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
## Additional Information
|
|
|
132 |
|
|
|
133 |
* AWS SDK for PHP: <http://aws.amazon.com/sdkforphp>
|
|
|
134 |
* Documentation: <http://docs.amazonwebservices.com/AWSSDKforPHP/latest/>
|
|
|
135 |
* License: <http://aws.amazon.com/apache2.0/>
|
|
|
136 |
* Discuss: <http://aws.amazon.com/forums>
|