Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Aws Sdk Php Laravel Package

aws/aws-sdk-php

AWS SDK for PHP (v3) provides a full-featured client library for calling Amazon Web Services from PHP 8.1+, including S3, DynamoDB, Glacier, and more. Install via Composer (aws/aws-sdk-php) and authenticate with AWS credentials.

View on GitHub
Deep Wiki
Context7
## Getting Started

### Minimal Setup in Laravel
1. **Installation**
   ```bash
   composer require aws/aws-sdk-php

For Laravel-specific integration (recommended):

composer require aws/aws-sdk-php-laravel
  1. Configuration Add AWS credentials to .env:

    AWS_ACCESS_KEY_ID=your_access_key
    AWS_SECRET_ACCESS_KEY=your_secret_key
    AWS_DEFAULT_REGION=us-east-1
    
  2. First Use Case: S3 File Upload (Unchanged)

    use Aws\S3\S3Client;
    
    $s3 = app(S3Client::class); // Laravel service provider injects config
    $result = $s3->putObject([
        'Bucket' => 'your-bucket',
        'Key'    => 'file.txt',
        'Body'   => fopen('local-file.txt', 'r'),
        'ACL'    => 'public-read'
    ]);
    
  3. New Use Case: MediaLive with MediaConnect Router

    use Aws\MediaLive\MediaLiveClient;
    
    $mediaLive = app(MediaLiveClient::class);
    $result = $mediaLive->createChannel([
        'Name' => 'MyChannel',
        'Inputs' => [
            [
                'Name' => 'Input1',
                'Type' => 'SDI',
                'Destinations' => [
                    [
                        'StreamName' => 'Output1',
                        'Type' => 'MEDIACONNECT_ROUTER', // New output type
                        'Settings' => [
                            'RouterName' => 'MyRouter',
                            'RouterInterfaceName' => 'Interface1'
                        ]
                    ]
                ]
            ]
        ]
    ]);
    
  4. Key Files to Reference

    • config/aws.php (auto-generated by Laravel package)
    • vendor/aws/aws-sdk-php/src/ (core SDK)
    • vendor/aws/aws-sdk-php-laravel/src/ (Laravel bindings)
    • New: vendor/aws/aws-sdk-php/src/Aws/MediaLive/ for MediaConnect Router
    • New: vendor/aws/aws-sdk-php/src/Aws/MarketplaceDiscovery/ for catalog operations

Implementation Patterns

1. Service Client Initialization (Unchanged)

Pattern: Use Laravel's service container for dependency injection

// In service provider
$this->app->singleton(MediaLiveClient::class, function ($app) {
    return new MediaLiveClient([
        'version' => 'latest',
        'region'  => config('aws.region'),
        'credentials' => [
            'key'    => config('aws.key'),
            'secret' => config('aws.secret'),
        ]
    ]);
});

2. Common Workflows (Updated with New Services)

MediaLive with MediaConnect Router:

// Create a channel with MediaConnect Router output
$mediaLive = app(MediaLiveClient::class);
$channel = $mediaLive->createChannel([
    'Name' => 'LiveStreamChannel',
    'Inputs' => [
        [
            'Name' => 'Input1',
            'Destinations' => [
                [
                    'StreamName' => 'RouterOutput',
                    'Type' => 'MEDIACONNECT_ROUTER',
                    'Settings' => [
                        'RouterName' => 'MyMediaConnectRouter',
                        'RouterInterfaceName' => 'PrimaryInterface'
                    ]
                ]
            ]
        ]
    ]
]);

Marketplace Discovery (New):

// Search for products in AWS Marketplace
$marketplace = app(Aws\MarketplaceDiscovery\MarketplaceDiscoveryClient::class);
$search = $marketplace->searchProducts([
    'Filters' => [
        'ProductType' => ['Software'],
        'Categories' => ['DevOps']
    ],
    'MaxResults' => 10
]);

Backup for EKS (New):

// Create a backup vault with EKS notification
$backup = app(Aws\Backup\BackupClient::class);
$vault = $backup->createBackupVault([
    'BackupVaultName' => 'eks-vault',
    'Notifications' => [
        'BackupJobFailedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'BackupJobCompletedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'CopyJobFailedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'CopyJobCompletedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'RestoreJobFailedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'RestoreJobCompletedNotification' => 'arn:aws:sns:us-east-1:123456789012:EKSBackupTopic',
        'NotificationType' => 'EKS_SPECIFIC' // New EKS-specific type
    ]
]);

3. Pagination Handling (Unchanged)

$iterator = $s3->getPaginator('ListObjects', [
    'Bucket' => 'bucket'
]);

foreach ($iterator as $page) {
    foreach ($page['Contents'] as $object) {
        // Process each object
    }
}

4. Error Handling (Updated with New Exceptions)

try {
    $ecr = app(Aws\ECR\ECRClient::class);
    $referrers = $ecr->listImageReferrers([
        'repositoryName' => 'my-repo',
        'imageId' => ['imageTag' => 'latest']
    ]);
} catch (Aws\ECR\Exception\UnableToListUpstreamImageReferrersException $e) {
    Log::error('ECR Referrers Error: ' . $e->getMessage());
    // Handle specific ECR exception
}

5. Configuration Management (Unchanged)

// Override config per environment
config([
    'aws.region' => 'eu-west-1',
    'aws.version' => '2012-10-17'
]);

// Per-client configuration for new services
$mediaLive = new Aws\MediaLive\MediaLiveClient([
    'region' => 'us-west-2',
    'version' => '2017-10-26' // MediaLive API version
]);

Gotchas and Tips

Common Pitfalls (Updated)

  1. Credentials Caching (Unchanged)

    • Clear cache when rotating keys:
      Aws\Common\Credentials\Credentials::clearStaticCache();
      
  2. Region Mismatches (Unchanged)

    • Always specify region explicitly for new services:
      $marketplace = new Aws\MarketplaceDiscovery\MarketplaceDiscoveryClient([
          'region' => 'us-east-1' // Marketplace Discovery is region-specific
      ]);
      
  3. New Service-Specific Quirks

    • MediaConnect Router:
      • Requires both RouterName and RouterInterfaceName for outputs.
      • Encrypted transport is automatic; no additional configuration needed.
    • Marketplace Discovery:
      • Search results are paginated by default (use NextToken for subsequent pages).
      • Some product details require additional API calls (e.g., GetProductById).
    • EKS Backup Notifications:
      • Must use NotificationType set to EKS_SPECIFIC for EKS-related events.
      • SNS topics must have proper IAM permissions for EKS backup events.
  4. Large File Uploads (Unchanged)

    • Use multipart upload for files >100MB.
  5. IAM Permissions (Updated)

    • New services require additional IAM policies:
      • MediaLive: mediaconnect:CreateRouter, mediaconnect:DescribeRouter
      • Marketplace Discovery: marketplacediscovery:SearchProducts, marketplacediscovery:GetProductById
      • EKS Backup: backup:CreateBackupVault, backup:PutBackupVaultNotifications

Debugging Tips (Updated)

  1. Enable Wire Logging (Unchanged)

    $client = new MediaLiveClient([
        'region' => 'us-west-2',
        'debug' => true,
        'logger' => new Aws\Common\Logger\LogLevelLogger(
            new Aws\Common\Logger\StreamLogger('php://stdout'),
            Aws\Common\Logger\LogLevel::DEBUG
        )
    ]);
    
  2. New Service-Specific Debugging

    • MediaConnect Router:
      • Verify router exists before creating channel outputs:
        $mediaconnect = app(Aws\MediaConnect\MediaConnectClient::class);
        $router = $mediaconnect->describeRouter(['Name' => '
        
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4