A Laravel 5+ (and 4) service provider for the AWS SDK for PHP

Overview

AWS Service Provider for Laravel 5/6/7/8

@awsforphp on Twitter Build Status Latest Stable Version Total Downloads Gitter

This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your Laravel and Lumen applications.

This README is for version 3.x of the service provider, which is implemented to work with Version 3 of the AWS SDK for PHP and Laravel 5.1.

Major Versions:

  • 3.x (YOU ARE HERE) - For laravel/framework:~5.1|~6.0|~7.0|~8.0 and aws/aws-sdk-php:~3.0
  • 2.x (2.0 branch) - For laravel/framework:5.0.* and aws/aws-sdk-php:~2.4
  • 1.x (1.0 branch) - For laravel/framework:4.* and aws/aws-sdk-php:~2.4

Jump To:

Getting Started

Installation

The AWS Service Provider can be installed via Composer by requiring the aws/aws-sdk-php-laravel package in your project's composer.json.

{
    "require": {
        "aws/aws-sdk-php-laravel": "~3.0"
    }
}

Then run a composer update

php composer.phar update

To use the AWS Service Provider, you must register the provider when bootstrapping your application.

Lumen

In Lumen find the Register Service Providers in your bootstrap/app.php and register the AWS Service Provider.

    $app->register(Aws\Laravel\AwsServiceProvider::class);

Laravel

In Laravel find the providers key in your config/app.php and register the AWS Service Provider.

    'providers' => array(
        // ...
        Aws\Laravel\AwsServiceProvider::class,
    )

Find the aliases key in your config/app.php and add the AWS facade alias.

    'aliases' => array(
        // ...
        'AWS' => Aws\Laravel\AwsFacade::class,
    )

Configuration

By default, the package uses the following environment variables to auto-configure the plugin without modification:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION (default = us-east-1)

To customize the configuration file, publish the package configuration using Artisan.

php artisan vendor:publish  --provider="Aws\Laravel\AwsServiceProvider"

The settings can be found in the generated config/aws.php configuration file. By default, the credentials and region settings will pull from your .env file.

return [
    'credentials' => [
        'key'    => env('AWS_ACCESS_KEY_ID', ''),
        'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
    ],
    'region' => env('AWS_REGION', 'us-east-1'),
    'version' => 'latest',
    
    // You can override settings for specific services
    'Ses' => [
        'region' => 'us-east-1',
    ],
];

Note that you can always delete the credentials line from this file if you'd like to use the default SDK Configuration Provider chain instead.

Referring Laravel 5.2.0 Upgrade guide, you must using config file instead of environment variable option if using php artisan config:cache.

Learn more about configuring the SDK on the SDK's User Guide.

Usage

In order to use the AWS SDK for PHP within your app, you need to retrieve it from the Laravel Service Container. The following example uses the Amazon S3 client to upload a file.

$s3 = App::make('aws')->createClient('s3');
$s3->putObject(array(
    'Bucket'     => 'YOUR_BUCKET',
    'Key'        => 'YOUR_OBJECT_KEY',
    'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));

If the AWS facade is registered within the aliases section of the application configuration, you can also use the following technique.

$s3 = AWS::createClient('s3');
$s3->putObject(array(
    'Bucket'     => 'YOUR_BUCKET',
    'Key'        => 'YOUR_OBJECT_KEY',
    'SourceFile' => '/the/path/to/the/file/you/are/uploading.ext',
));

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.

Opening Issues

If you encounter a bug with aws-sdk-php-laravel 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-laravel, PHP version and OS you’re using. Please include a stack trace and reduced repro 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.

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

Comments
  • AWS Facade Support

    AWS Facade Support

    Hi guys,

    Laravel team member here offering an AWS Facade to bring usage of the SDK more inline with Laravel's beautiful syntax. A simple change, but may seem more familiar to users of the framework.

    $s3 = AWS::get('s3');
    

    Test is included, and the README has been updated accordingly.

    Thanks for the Laravel specific package, and all the great AWS services!

    Dayle.

    feature-request 
    opened by daylerees 21
  • Allow loading of SDK via Dependency Injection

    Allow loading of SDK via Dependency Injection

    I avoid the use of Facades in my application as much as possible, leveraging Laravels IoC/DI capabilities to load classes throughout my application. This change would more easily facilitate that.

    opened by mattzuba 18
  • Laravel 7 Support

    Laravel 7 Support

    Issue: #178

    Description of changes:

    Add support for Laravel 7

    Closes #171. Closes #178.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by matthewnessworthy 16
  • Service provider not deferred

    Service provider not deferred

    The package method (called in boot) does a lot of file/directory checks when it is called. If you have an app that does a lot of things NOT related to AWS this will cause a problem. Would it be possible to set the service provider to be deferred?

    on-hold 
    opened by lonnylot 16
  • Updated to support both laravel 4 and laravel 5

    Updated to support both laravel 4 and laravel 5

    This makes sure we're compatible with all versions of laravel 4 and laravel 5.

    I've also updated to phpunit 4, and moved to psr-4 without modifying the directory structure.

    opened by GrahamCampbell 15
  • The specified queue does not exist for this wsdl version

    The specified queue does not exist for this wsdl version

    Getting below error..

    My queue region is "ap-south-1" AWS.SimpleQueueService.NonExistentQueue (client): The specified queue does not exist for this wsdl version.

    guidance 
    opened by bhalsodkhushal 14
  • Call never ends iotDataPlane

    Call never ends iotDataPlane

    Call never ends and never returns from getThingShadow, browser keeps quering..

    $client = AWS::createClient('iotDataPlane');
    $result = $client->getThingShadow([
         'thingName' => $thingName, // REQUIRED
        ]);
    

    Also same with

    $client->publish([ 'payload' => '{"test": "0"}', 'topic' => "test", 'qos' => 0]);
    

    Topic gets published but it never leaves publish method.

    What I am doing wrong ?

    service-api 
    opened by misiek303 14
  • Add Laravel 8 support

    Add Laravel 8 support

    Description of changes: Adds support for Laravel 8

    Changes:

    • Bump supported version of Illuminate/support to ^8.0
    • Bump the version of dotenv to include support for ^5.0
    • Update docs to show support for Laravel 8

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by Kussie 13
  • Security Credential issue.

    Security Credential issue.

    Trying to just upload files. It feels like my key and secret arent working but i've double checked they are the right ones. Codes copied straight out of the readme.

    Error:

    Error retrieving credentials from the instance profile metadata server. 
    When you are not running inside of Amazon EC2, you must provide your AWS
    access key ID and secret access key in the "key" and "secret" options when 
    creating a client or provide an instantiated
    Aws\Common\Credentials\CredentialsInterface object.
    ([curl] 7: Failed to connect to 169.254.169.254: Host is down [url] 
    http://169.254.169.254/latest/meta-data/iam/security-credentials/)
    

    Function:

    $s3 = AWS::get('s3');
    $s3->putObject(array(
        'Bucket'        => '[bucketname]',
        'Key'           => '[key]',
        'SourceFile'    => '[file]'
    )); 
    
    bug 
    opened by allanhortle 12
  • Compatibility with Lumen

    Compatibility with Lumen

    The AwsServiceProvider currently doesn't work in a Lumen project, because the config_path helper function isn't available.

    Would it be reasonable to change line 9 ($this->publishes...) to first check to see if config_helper has been defined?

    From what I can tell $this->publishes... doesn't need to be run in a Lumen app anyway, and I can still configure Aws using my .env file.

    I'd be happy to submit a PR, just wanted to see if this was the right approach.

    feature-request 
    opened by jszobody 11
  • dynamodb session handler

    dynamodb session handler

    Where is the best place (laravel code file) to drop in AWS dynamodb session handler in laravel 4, and any suggestions on changing configs to accomodate?

    http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/feature-dynamodb-session-handler.html

    Many thanks

    feature-request 
    opened by andy3rdworld 11
  • Fix jump to link

    Fix jump to link

    Issue #, if available: readme link error

    Description of changes: fix readme jump to link

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by getsolaris 0
  • Change the default region env variable to be consistent with the Laravel env example file

    Change the default region env variable to be consistent with the Laravel env example file

    Describe the feature

    Since v5.8 Laravel has provided example .env variables for configuring AWS settings, one of which is the AWS_DEFAULT_REGION key for configuring the default region (https://github.com/laravel/laravel/blob/5.8/.env.example). This package sets us-east-1 as the default region unless you define an alternative using the AWS_REGION key in your .env.

    Suggest changing the environment key to use the same key that is already defined in the Laravel .env.example so that an effectively duplicate key does not need to be added. This also keeps it consistent with the other keys Laravel and the package share.

    Use Case

    No duplication of keys/values and keeps things consistent.

    Proposed Solution

    Update both config/aws_default.php and config/aws_publish.php to:

    Replace

    'region' => env('AWS_REGION', 'us-east-1'),
    

    With

    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    

    Other Information

    No response

    Acknowledgements

    • [ ] I may be able to implement this feature request
    • [ ] This feature might incur a breaking change

    SDK version used

    3.7

    Environment details (OS name and version, etc.)

    Fedora 36

    feature-request needs-triage 
    opened by peppermintology 0
  • php artisan vendor:publish command says

    php artisan vendor:publish command says "Unable to locate publishable resources."

    Describe the bug

    I have a Lumen 8.0 app into which I'm trying to install this SDK.

    1. I install via composer: composer require aws/aws-sdk-php-laravel
    2. I add this line ($app->register(Aws\Laravel\AwsServiceProvider::class);) to bootstrap/app.php
    3. I confirm I have the proper environment variables in place
    4. I run php artisan vendor:publish --provider="Aws\Laravel\AwsServiceProvider"
    5. I get this output: Unable to locate publishable resources. Publishing complete.

    I tried manually importing that class:

    use Aws\Laravel\AwsServiceProvider;
    $app->register(AwsServiceProvider::class);
    // and nothing
    

    I tried running composer dumpautoload and then the vendor command and nothing.

    I've found posts on Stack Overflow which suggest running the php artisan vendor:publish alone. That command output does not include anything related to AWS.

    I even tried this suggestion found on the Lumen Vendor Publish package: https://github.com/laravelista/lumen-vendor-publish/issues/16#issuecomment-917424678

    Can you offer any insights into why this might be failing? I suspect I could simply copy vendor/aws/aws-sdk-php-laravel/config/aws_publish.php into my config/ directory as aws.php but given you have specific instructions for Lumen I thought I'd ask here first.

    Expected Behavior

    I expected the file config/aws.php to be created as per the instructions in the readme.

    Current Behavior

    When I run this command:

    $ php artisan vendor:publish  --provider="Aws\Laravel\AwsServiceProvider"
    

    I get the following output:

    Unable to locate publishable resources.
    Publishing complete.
    

    Reproduction Steps

    1. I install via composer: composer require aws/aws-sdk-php-laravel
    2. I add this line ($app->register(Aws\Laravel\AwsServiceProvider::class);) to bootstrap/app.php
    3. I confirm I have the proper environment variables in place
    4. I run php artisan vendor:publish --provider="Aws\Laravel\AwsServiceProvider"
    5. I get this output: Unable to locate publishable resources. Publishing complete.

    Possible Solution

    It appears that the publish command can't find the package, but it's clearly there when viewing the vendor folder.

    Additional Information/Context

    No response

    SDK version used

    3.7

    Environment details (OS name and version, etc.)

    Mac OS 10.15.7 (19H1615)

    bug needs-triage 
    opened by commadelimited 0
  • Add .gitattributes

    Add .gitattributes

    Description of changes:

    Let's ignore these files and folder while installing this package via composer.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by sunaoka 0
  • Error retrieving credentials from the instance profile metadata service.

    Error retrieving credentials from the instance profile metadata service.

    Confirm by changing [ ] to [x] below:

    Version of AWS SDK for PHP? Example: v3.133.6

    • get SDK version by printing the output of Aws\Sdk::VERSION in your code
    • if the SDK was installed via composer you can see the version installed with composer show -i

    Version of AWS Service Provider for Laravel? 3.6

    Version of Laravel (php artisan --version)? 8.15.0

    Version of PHP (php -v)? 7.4.1

    Describe the question After running the command: php artisan config:cache for some reason I always got this error:

    Error retrieving credentials from the instance profile metadata service
    

    If I'll use the following command: php artisan config:clear it's work fine. Now, to work with the socket server I need those cached config files. Basically, as I understand if I will cache the configuration file, the SDK cannot see the connection credentials. Basically, the issue is not only with only one AWS service it's with all of them (SNS, SES, S3, SQS, etc).

    guidance needs-triage 
    opened by arthimann 1
  • Laravel environment match

    Laravel environment match

    Description of changes: Since Laravel 5.7 where they added the default environment variables for AWS to the .env.example the region variable has been called AWS_DEFAULT_REGION, however this package by default looks for AWS_REGION and then falls back to us-east-1.

    This PR adjusts the confirm file to first look for AWS_REGION else AWS_DEFAULT_REGION else us-east-1.

    This is a non-breaking change.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by hailwood 1
Releases(3.7.0)
Most Advance online restaurant menu, food delivery system, online restaurant menu, free online restaurant menu, free online restaurant menu app, online restaurant menu service provider

Buffet Box online menu and cloud kitchen Most Advance online restaurant menu, online restaurant menu, free online restaurant menu, free online restaur

null 20 Oct 28, 2022
Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs

Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.

Thuong Le 77 Dec 19, 2022
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login

Facebook SDK for PHP (v5) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

Meta Archive 3.1k Dec 30, 2022
Supermeteor is PHP SDK use to create cloud message: whatsapp, sms and email etc

Supermeteor Supermeteor is PHP SDK use to create cloud message: whatsapp, sms and email etc How to use install using composer composer require superme

null 0 Jul 15, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
A RESTful and extendable Backend as a Service that provides instant backend to develop sites and apps faster, with dead-simple integration for JavaScript, iOS, Android and more.

Welcome to hook ![Gitter](https://badges.gitter.im/Join Chat.svg) hook is a RESTful, extendable Backend as a Service that provides instant backend to

doubleleft 762 Dec 30, 2022
Fully unit tested Facebook SDK v5 integration for Laravel & Lumen

Laravel Facebook SDK A fully unit-tested package for easily integrating the Facebook SDK v5 into Laravel and Lumen 5.0, 5.1, 5.2, & 5.3. This is packa

Sammy Kaye Powers 697 Nov 6, 2022
Paynow SDK Laravel integration

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Alfred Tanaka Kudiwahove 2 Sep 20, 2021
Unofficial Firebase Admin SDK for PHP

Firebase Admin PHP SDK Table of Contents Overview Installation Documentation Support License Overview Firebase provides the tools and infrastructure y

kreait 1.9k Jan 3, 2023
Notion PHP SDK

Notion PHP SDK This is an unofficial PHP SDK for the new public Notion API. It's work in progress as we didn't get the change to be included to the pr

Codecycler 43 Nov 29, 2022
爱发电非官方简易 PHP SDK

afdian-php-sdk 爱发电非官方简易 PHP SDK by Akkariin 这是一个简单的 SDK,可以用于查询爱发电的订单和赞助者信息 Installation 将项目 clone 到本地即可 git clone https://github.com/ZeroDream-CN/afdi

ZeroDream-CN 17 Nov 7, 2022
PHP SDK to interact with the Casper Network nodes via RPC

casper-php-sdk PHP SDK to interact with Casper Network nodes via RPC Install composer require make-software/casper-php-sdk Examples RPC Client: $node

MAKE Technology LLC 7 May 8, 2022
A complete Notion SDK for PHP developers.

notion-sdk-php A complete Notion SDK for PHP developers. Installation composer require mariosimao/notion-php Getting started A Notion token will be n

Mario Simão 77 Nov 29, 2022
SDK of the LINE Login API for PHP

LINE Login for PHP SDK of the LINE Login API for PHP Documentation See the official API documentation for more information. Installation Use the packa

null 4 Sep 15, 2022
PHP SDK - Flexie CRM fiskalizimi solution

PHP SDK - Flexie CRM fiskalizimi solution Fiskalizimi PHP SDK allows you to talk and generate your e-invoices programmatically from your own solution

Flexie CRM 3 Dec 30, 2021
PHP Digital Green Certificate SDK

Digital Green Certificate SDK PHP Indice Contesto Installazione Uso Licenza Dettaglio licenza Contesto Attenzione, questo repository è derivato dalle

null 13 Jun 20, 2022
Esse SDK em PHP foi desenvolvido no intuito de tornar mais prático a integração com nossa API.

Sobre Beedoo SDK Acessar documentação completa da Beedoo API. A API é organizada seguindo a arquitetura REST, boas práticas, convenções e padrões como

Beedoo Edtech 5 Dec 2, 2021