{"id":18550301,"url":"https://github.com/xp-forge/aws","last_synced_at":"2026-04-10T20:01:35.370Z","repository":{"id":142764628,"uuid":"614074085","full_name":"xp-forge/aws","owner":"xp-forge","description":"AWS Core for the XP Framework","archived":false,"fork":false,"pushed_at":"2025-05-04T17:18:02.000Z","size":169,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-04T18:23:49.736Z","etag":null,"topics":["aws","aws-bedrock","aws-credentials","aws-sdk","aws-services","aws-signature-v4","aws-sso","php7","php8","s3","streaming","xp-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-14T20:51:30.000Z","updated_at":"2025-05-04T17:17:47.000Z","dependencies_parsed_at":"2023-12-02T11:24:25.844Z","dependency_job_id":"10293319-4ced-4009-99c6-2e467045c4ba","html_url":"https://github.com/xp-forge/aws","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Faws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Faws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Faws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Faws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/aws/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254120180,"owners_count":22017954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-bedrock","aws-credentials","aws-sdk","aws-services","aws-signature-v4","aws-sso","php7","php8","s3","streaming","xp-framework"],"created_at":"2024-11-06T21:04:10.038Z","updated_at":"2025-10-29T13:16:58.029Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"AWS Core for the XP Framework\n========================================================================\n\n[![Build status on GitHub](https://github.com/xp-forge/aws/workflows/Tests/badge.svg)](https://github.com/xp-forge/aws/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/aws/version.svg)](https://packagist.org/packages/xp-forge/aws)\n\nProvides common AWS functionality in a low-level and therefore lightweight library (*less than 3% of the size of the official PHP SDK!*)\n\nInvoking a lambda\n-----------------\n\n```php\nuse com\\amazon\\aws\\{Credentials, ServiceEndpoint};\nuse util\\Secret;\nuse util\\cmd\\Console;\nuse util\\log\\Logging;\n\n$credentials= new Credentials($accessKey, new Secret($secretKey));\n\n$api= (new ServiceEndpoint('lambda', $credentials))-\u003ein('eu-central-1')-\u003eversion('2015-03-31');\n$api-\u003esetTrace(Logging::all()-\u003etoConsole());\n\n$r= $api-\u003eresource('/functions/greet/invocations')-\u003etransmit(['name' =\u003e getenv('USER')]);\n\nConsole::writeLine($r);\nConsole::writeLine($r-\u003evalue());\n```\n\nCredential providers\n--------------------\nAWS credentials are stored in various places, depending on the runtime environment. The *CredentialProvider* class supports the following:\n\n* **Environment variables**: Uses `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and (if present) `AWS_SESSION_TOKEN`\n* **Shared credentials and config files**: Reads credentials from `~/.aws/config` and (if present) `~/.aws/credentials` (honoring alternative locations set via environment variables)\n* **SSO**: Uses configured SSO and the cached credentials created by AWS CLI's [login](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sso/login.html) command, including SSO session support\n* **Amazon ECS container credentials**: Uses the container API to fetch (and refresh, if necessary) the credentials\n\nSee https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html\n\nSharing a S3 resource\n---------------------\nThe following creates a pre-signed link which is valid for 3 minutes:\n\n```php\nuse com\\amazon\\aws\\{ServiceEndpoint, CredentialProvider};\nuse util\\cmd\\Console;\n\n$s3= (new ServiceEndpoint('s3', CredentialProvider::default()))\n  -\u003ein('eu-central-1')\n  -\u003eusing('my-bucket')\n;\n$link= $s3-\u003esign('/path/to/resource.png', timeout: 180);\n\nConsole::writeLine($link);\n```\n\nStreaming uploads to S3\n-----------------------\nS3 doesn't double-encode its paths when signing them (see https://github.com/aws/aws-sdk-php/pull/633), pass `S3Key` instances to support arbitrary filenames:\n\n```php\nuse com\\amazon\\aws\\api\\SignatureV4;\nuse com\\amazon\\aws\\{ServiceEndpoint, CredentialProvider, S3Key};\nuse io\\File;\nuse util\\cmd\\Console;\n\n$s3= (new ServiceEndpoint('s3', CredentialProvider::default()))\n  -\u003ein('eu-central-1')\n  -\u003eusing('my-bucket')\n;\n\n$file= new File($argv[1]);\n$file-\u003eopen(File::READ);\n\ntry {\n  $transfer= $s3-\u003eresource(new S3Key('target', $file-\u003efilename))-\u003eopen('PUT', [\n    'x-amz-content-sha256' =\u003e SignatureV4::UNSIGNED, // Or calculate from file\n    'Content-Type'         =\u003e 'text/plain',\n    'Content-Length'       =\u003e $file-\u003esize(),\n  ]);\n  while (!$file-\u003eeof()) {\n    $transfer-\u003ewrite($file-\u003eread());\n  }\n  $response= $transfer-\u003efinish();\n\n  Console::writeLine($response);\n} finally {\n  $file-\u003eclose();\n}\n```\n\nStreaming responses from Bedrock AI models\n------------------------------------------\nSee https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html:\n\n```php\nuse com\\amazon\\aws\\{ServiceEndpoint, CredentialProvider};\nuse util\\cmd\\Console;\n\n$model= 'anthropic.claude-3-5-sonnet-20240620-v1:0';\n$runtime= (new ServiceEndpoint('bedrock', CredentialProvider::default()))\n  -\u003eusing('bedrock-runtime.')\n  -\u003ein('eu-central-1')\n;\n\n$response= $runtime-\u003eresource('/model/{0}/converse-stream', [$model])-\u003etransmit([\n  'system' =\u003e [['text' =\u003e 'Use informal language']],\n  'messages' =\u003e [\n    ['role' =\u003e 'user', 'content' =\u003e [['text' =\u003e $argv[1]]]],\n  ],\n  'inferenceConfig' =\u003e [\n    'maxTokens'   =\u003e 1000,\n    'temperature' =\u003e 0.5,\n  ],\n]);\nforeach ($response-\u003eevents() as $event) {\n  Console::writeLine($event-\u003eheader(':event-type'), ': ', $event-\u003evalue());\n}\n```\n\n\nSee also\n--------\n* [AWS Lambda for XP Framework](https://github.com/xp-forge/lambda)\n* [AWS Lambda Webservices for the XP Framework](https://github.com/xp-forge/lambda-ws)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Faws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Faws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Faws/lists"}