Convert Figma logo to code with AI

aws logoaws-sdk-php

Official repository of the AWS SDK for PHP (@awsforphp)

6,015
1,219
6,015
46

Top Related Projects

23,156

Guzzle, an extensible PHP HTTP client

29,705

The Symfony PHP framework

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

13,312

Abstraction for local and remote filesystems

Standards either proposed or approved by the Framework Interop Group

Quick Overview

The aws/aws-sdk-php repository contains the official AWS SDK for PHP, providing developers with a powerful and flexible way to interact with various AWS services programmatically. This SDK simplifies the process of integrating AWS functionality into PHP applications, offering a comprehensive set of tools and APIs for managing AWS resources.

Pros

  • Comprehensive coverage of AWS services
  • Well-documented and regularly updated
  • Supports both synchronous and asynchronous operations
  • Integrates seamlessly with popular PHP frameworks and tools

Cons

  • Large library size, which may impact application performance
  • Steep learning curve for developers new to AWS
  • Some complex operations may require additional configuration
  • Occasional breaking changes between major versions

Code Examples

  1. Creating an S3 client and uploading a file:
use Aws\S3\S3Client;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

$result = $s3->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => fopen('/path/to/file', 'r')
]);
  1. Sending a message to an SQS queue:
use Aws\Sqs\SqsClient;

$sqs = new SqsClient([
    'version' => 'latest',
    'region'  => 'us-east-1'
]);

$result = $sqs->sendMessage([
    'QueueUrl'    => 'https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue',
    'MessageBody' => 'Hello, AWS!'
]);
  1. Retrieving items from a DynamoDB table:
use Aws\DynamoDb\DynamoDbClient;

$dynamodb = new DynamoDbClient([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

$result = $dynamodb->scan([
    'TableName' => 'MyTable',
    'Limit'     => 10
]);

Getting Started

To start using the AWS SDK for PHP, follow these steps:

  1. Install the SDK using Composer:

    composer require aws/aws-sdk-php
    
  2. Set up your AWS credentials:

    use Aws\Credentials\CredentialProvider;
    
    $provider = CredentialProvider::defaultProvider();
    
  3. Create a client for the desired AWS service:

    use Aws\S3\S3Client;
    
    $s3 = new S3Client([
        'version' => 'latest',
        'region'  => 'us-west-2',
        'credentials' => $provider
    ]);
    
  4. Start using the client to interact with AWS services:

    $result = $s3->listBuckets();
    foreach ($result['Buckets'] as $bucket) {
        echo $bucket['Name'] . "\n";
    }
    

Competitor Comparisons

23,156

Guzzle, an extensible PHP HTTP client

Pros of Guzzle

  • More versatile and can be used for various HTTP requests, not limited to AWS services
  • Simpler API and easier to learn for general HTTP client needs
  • Actively maintained with frequent updates and community support

Cons of Guzzle

  • Lacks built-in AWS-specific features and optimizations
  • Requires additional configuration and code for AWS authentication and specialized services
  • May need extra dependencies for advanced AWS functionalities

Code Comparison

AWS SDK for PHP:

use Aws\S3\S3Client;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);
$result = $s3->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => 'Hello, world!'
]);

Guzzle:

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('PUT', 'https://s3.us-west-2.amazonaws.com/my-bucket/my-object', [
    'body' => 'Hello, world!',
    'headers' => [
        'Authorization' => 'AWS4-HMAC-SHA256 ...' // AWS signature required
    ]
]);

The AWS SDK for PHP provides a more streamlined approach for AWS-specific operations, while Guzzle offers a general-purpose HTTP client that requires additional setup for AWS interactions.

29,705

The Symfony PHP framework

Pros of Symfony

  • More comprehensive framework for web application development
  • Larger community and ecosystem with numerous bundles and components
  • Flexible and modular architecture allowing for customization

Cons of Symfony

  • Steeper learning curve due to its extensive features and concepts
  • Potentially heavier and slower for simple applications compared to lightweight SDKs
  • May require more setup and configuration for basic projects

Code Comparison

Symfony (routing example):

use Symfony\Component\Routing\Annotation\Route;

class ProductController extends AbstractController
{
    #[Route('/product/{id}', name: 'product_show')]
    public function show(int $id): Response
    {
        // ...
    }
}

AWS SDK for PHP (S3 example):

use Aws\S3\S3Client;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

$result = $s3->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => 'Hello, world!'
]);

The Symfony framework provides a full-stack solution for web development, while the AWS SDK for PHP focuses specifically on interacting with AWS services. Symfony offers more extensive features for building complex web applications, whereas the AWS SDK is tailored for AWS integration. The choice between them depends on the project's requirements and scope.

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

Pros of Laravel

  • Full-featured web application framework with built-in tools for routing, authentication, and database management
  • Extensive ecosystem with a large community and many packages available
  • Follows MVC architecture, promoting clean and organized code structure

Cons of Laravel

  • Steeper learning curve for beginners compared to using a simple SDK
  • May be overkill for small projects or those primarily focused on AWS integration
  • Requires more setup and configuration than a standalone SDK

Code Comparison

Laravel (routing example):

Route::get('/users', function () {
    return User::all();
});

AWS SDK for PHP (S3 example):

$s3Client = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);
$result = $s3Client->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => 'Hello, world!'
]);

Summary

Laravel is a comprehensive PHP framework for web application development, while the AWS SDK for PHP is specifically designed for interacting with AWS services. Laravel offers a complete ecosystem for building web applications, including features like routing, ORM, and authentication. The AWS SDK, on the other hand, provides a focused set of tools for AWS integration. Choose Laravel for full-stack web development projects, and the AWS SDK for PHP when your primary goal is to interact with AWS services in a PHP environment.

13,312

Abstraction for local and remote filesystems

Pros of Flysystem

  • Provides a unified, abstracted interface for multiple storage systems (local, S3, FTP, etc.)
  • Simpler API with fewer methods, making it easier to learn and use
  • Lightweight and focused solely on file storage operations

Cons of Flysystem

  • Limited to file storage operations, lacking broader AWS service support
  • May require additional configuration for advanced S3 features
  • Less frequent updates compared to the AWS SDK

Code Comparison

AWS SDK for PHP:

$s3 = new Aws\S3\S3Client([/* config */]);
$result = $s3->putObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'my-object',
    'Body'   => fopen('/path/to/file', 'r')
]);

Flysystem:

$filesystem = new League\Flysystem\Filesystem($adapter);
$filesystem->write('path/to/file.txt', 'contents');

Summary

Flysystem offers a simpler, more abstract approach to file storage across multiple systems, while the AWS SDK for PHP provides comprehensive access to AWS services. Flysystem is ideal for projects requiring storage flexibility, while the AWS SDK is better suited for deep AWS integration. Choose based on your project's specific needs and complexity.

Standards either proposed or approved by the Framework Interop Group

Pros of fig-standards

  • Focuses on PHP standards and best practices, benefiting the entire PHP community
  • Collaborative effort with input from various PHP experts and organizations
  • Provides guidelines for interoperability between different PHP projects

Cons of fig-standards

  • Not a functional library or SDK, requiring separate implementation
  • May have slower adoption rates compared to widely-used SDKs
  • Limited scope to PHP standards, not providing specific cloud service integrations

Code Comparison

fig-standards (PSR-4 autoloading example):

<?php
namespace Vendor\Package;

class ClassName
{
    // ...
}

aws-sdk-php (S3 client example):

<?php
use Aws\S3\S3Client;

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

Summary

fig-standards is a set of PHP standards and best practices, while aws-sdk-php is a specific SDK for AWS services. fig-standards benefits the broader PHP ecosystem but requires separate implementation. aws-sdk-php provides ready-to-use AWS integrations but is limited to AWS services. The choice between them depends on whether you need general PHP guidelines or specific AWS functionality.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AWS SDK for PHP - Version 3

Total Downloads Apache 2 License Gitter codecov

The AWS SDK for PHP makes it easy for developers to access Amazon Web Services in their PHP code, and build robust applications and software using services like Amazon S3, Amazon DynamoDB, Amazon Glacier, etc. You can get started in minutes by installing the SDK through Composer or by downloading a single zip or phar file from our latest release.

Jump To:

Getting Started

  1. Sign up for AWS – Before you begin, you need to sign up for an AWS account and retrieve your AWS credentials.
  2. Minimum requirements – To run the SDK, your system will need to meet the minimum requirements, including having PHP >= 7.2.5. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+ compiled with a TLS backend (e.g., NSS or OpenSSL).
  3. Install the SDK – Using Composer is the recommended way to install the AWS SDK for PHP. The SDK is available via Packagist under the aws/aws-sdk-php package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:
    composer require aws/aws-sdk-php
    
    Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means.
  4. Using the SDK – The best way to become familiar with how to use the SDK is to read the User Guide. The Getting Started Guide will help you become familiar with the basic concepts.
  5. Beta: Removing unused services — To date, there are over 300 AWS services available for use with this SDK. You will likely not need them all. If you use Composer and would like to learn more about this feature, please read the linked documentation.

Quick Examples

Create an Amazon S3 client

<?php
// Require the Composer autoloader.
require 'vendor/autoload.php';

use Aws\S3\S3Client;

// Instantiate an Amazon S3 client.
$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-west-2'
]);

Upload a file to Amazon S3

<?php
// Upload a publicly accessible file. The file size and type are determined by the SDK.
try {
    $s3->putObject([
        'Bucket' => 'my-bucket',
        'Key'    => 'my-object',
        'Body'   => fopen('/path/to/file', 'r'),
        'ACL'    => 'public-read',
    ]);
} catch (Aws\S3\Exception\S3Exception $e) {
    echo "There was an error uploading the file.\n";
}

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.

This SDK implements AWS service APIs. For general issues regarding the AWS services and their limitations, you may also take a look at the Amazon Web Services Discussion Forums.

Maintenance and support for SDK major versions

For information about maintenance and support for SDK major versions and their underlying dependencies, see the following in the AWS SDKs and Tools Shared Configuration and Credentials Reference Guide:

Opening Issues

If you encounter a bug with aws-sdk-php we would like to hear about it. Search the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of aws-sdk-php, PHP version and OS you’re using. Please include a stack trace and a simple workflow to reproduce the case when appropriate, too.

The GitHub issues are intended for bug reports and feature requests. For help and questions with using aws-sdk-php please make use of the resources listed in the Getting Help section. There are limited resources available for handling issues and by keeping the list of open issues lean we can respond in a timely manner.

Features

Contributing

We work hard to provide a high-quality and useful SDK for our AWS services, and we greatly value feedback and contributions from our community. Please review our contributing guidelines before submitting any issues or pull requests to ensure we have all the necessary information to effectively respond to your bug report or contribution.

Resources

  • User Guide – For both getting started and in-depth SDK usage information
  • API Docs – For details about operations, parameters, and responses
  • Blog – Tips & tricks, articles, and announcements
  • Sample Project - A quick, sample project to help get you started
  • Forum – Ask questions, get help, and give feedback
  • Issues – Report issues, submit pull requests, and get involved (see Apache 2.0 License)

Related AWS Projects