{"id":33945508,"url":"https://github.com/rtek/aws-gen","last_synced_at":"2026-04-09T04:31:01.111Z","repository":{"id":62537948,"uuid":"171152523","full_name":"rtek/aws-gen","owner":"rtek","description":"Generate PHP classes for AWS data types","archived":false,"fork":false,"pushed_at":"2019-03-17T20:08:01.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-14T06:39:01.750Z","etag":null,"topics":["aws","code","dynamodb","ec2","generator","object","php","rds","s3","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-17T17:46:32.000Z","updated_at":"2019-03-17T20:08:02.000Z","dependencies_parsed_at":"2022-11-02T16:15:36.432Z","dependency_job_id":null,"html_url":"https://github.com/rtek/aws-gen","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rtek/aws-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtek%2Faws-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtek%2Faws-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtek%2Faws-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtek%2Faws-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtek","download_url":"https://codeload.github.com/rtek/aws-gen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtek%2Faws-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31586403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","code","dynamodb","ec2","generator","object","php","rds","s3","wrapper"],"created_at":"2025-12-12T17:53:10.723Z","updated_at":"2026-04-09T04:31:01.104Z","avatar_url":"https://github.com/rtek.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AwsGen - PHP classes for the [AWS SDK](https://github.com/aws/aws-sdk-php)\n\nAwsGen generates strictly typed PHP classes that allow you to use \nAmazon Web Services with objects instead of arrays.\n\n## Installation\n`\\Rtek\\AwsGen` has no runtime component, so require it as a development dependency:\n```\n$ composer require --dev rtek/aws-gen\n```\n\n## Why Bother?\n\nAWS has approximately 170 services with ~18,000 types. The SDK provides access \nto these services using `\\ArrayAccess` and rich runtime [metadata](https://github.com/aws/aws-sdk-php/tree/master/src/data), \nbut does not offer code-completion by realizing the API in PHP classes*.\n\n`\\Rtek\\AwsGen` will generate PHP classes for the services and operations that \nyou choose, while allowing you to use the underlying SDK at all times. \n\nYou can treat these classes as read-only, or embed them in your project\nas the basis for more sophisticated wrappers.\n\n\u003csub\u003e*If you used AwsGen for all services, there would be ~10x the number of files as the SDK\u003c/sub\u003e\n\n## An Example: S3 Service\n\n### Console generation\n```\n$ vendor/bin/aws-gen generate\n\n Search Service:\n \u003e s3\n\n Choose Service [Search again]:\n  [0] Stop searching\n  [1] Search again\n  [2] s3\n  [3] s3:2006-03-01\n  [4] s3control\n  [5] s3control:2018-08-20\n \u003e 2\n\n What namespace? [App\\AwsGen\\]:\n \u003e App\\AwsGen\\\n\n What output directory? [src]:\n \u003e src\n\n PSR-4 namespace prefix? [App\\AwsGen\\]:\n  [0]\n  [1] App\\\n  [2] App\\AwsGen\\\n \u003e 1\n\nGenerating: s3\n==============\n\n Added s3:latest\n Generating...\n ...Complete\n\n [OK] Wrote 294 files to src/AwsGen/\n```\n\n### PHP generation\n```php\n\u003c?php\n\nnamespace App;\n\nuse Rtek\\AwsGen\\Generator;\nuse Rtek\\AwsGen\\Writer\\DirWriter;\n\n$gen = new Generator('App\\\\AwsGen');  //generate classes to the 'App\\AwsGen' namespace\n$gen-\u003eaddService('s3', '2006-03-01'); //add the s3 service, version optional\nDirWriter::create('src')              //set the root directory to write the files\n    -\u003esetPsr4Prefix('App\\\\')          //optionally set a PSR4 prefix\n    -\u003ewrite($gen);                    //writes App\\AwsGen\\S3 to src/AwsGen/S3\n```\n\n### Usage\n```php\n\u003c?php \n\nnamespace App;\n\nuse App\\AwsGen\\S3 as S3;\n\n$config = [\n    'credentials' =\u003e [\n        'key' =\u003e '***',\n        'secret' =\u003e '***',\n    ],\n    'region' =\u003e 'us-east-1', \n];\n//generated client extends `\\Aws\\S3Client` with the same config as SDK except\n//for `version` which is overridden by the specified generation version\n$client = new S3\\S3Client($config); \n                                    \n//the operation input create(...) contains required params\n$input = S3\\CreateBucketRequest::create($bucket = 'test'); \n\n//they can be set directly just like optional params\n$input-\u003eBucket($bucket)-\u003eACL('public-read');               \n              \n//operation names are the same as SDK   \n$output = $client-\u003ecreateBucket($input);\n\n//the operation output has getters that match the SDK \necho \"Bucket created at: {$output-\u003eLocation()}\\n\"; \n\n//supports fluent interface\n$output = $client-\u003eputObject(\n    S3\\PutObjectRequest::create($bucket, $key = 'foo.txt')\n        -\u003eBody('bar baz')-\u003eContentType('text/plain')\n);   \n\n//`\\ArrayAccess` works as usual since output classes extend `\\Aws\\Result`\necho \"Created object {$key} with ETag {$output['ETag']}\\n\"; \n\n//supports setting values via array by constructor\n$input = new S3\\GetObjectRequest([\n    'Bucket' =\u003e $bucket,\n    'Key' =\u003e $key,\n]);\n$output = $client-\u003egetObject($input);\necho \"The object has a body of: {$output-\u003eBody()}\\n\";\n\n//you can bypass AwsGen classes by passing the array argument to the client\n$result = $client-\u003egetObject([\n    'Bucket' =\u003e $bucket,\n    'Key' =\u003e $key,\n]);\necho \"The object still has a body of: {$result['Body']}\\n\";\n\n//`\\IteratorAggregate` is implemented for iterable properties\n$output = $client-\u003elistObjectsV2(S3\\ListObjectsV2Request::create($bucket));\nforeach ($output-\u003eContents() as $object) {\n    $client-\u003edeleteObject(S3\\DeleteObjectRequest::create($bucket, $object-\u003egetKey()));\n}\n```\n\n## Terms\n\n* `Service`\n    * An AWS service that has a `Client` and metadata\n    * Contains multiple `Operation` and `Shape`\n    * e.g. `S3`, `DynamoDb`, `Ec2`\n* `Operation`\n    * An AWS API call that does something\n    * Has an `Input` and an `Output`\n    * e.g. `DynamoDb\\DynamoDbClient::putItem()`, `S3\\S3Client::getObject()`\n* `Shape`\n    * An AWS type that can be serialized as an associative array\n    * Accessors are read and write\n    * e.g. `S3\\ObjectList`, `Ec2\\Instance`\n* `Input`\n    * A `Shape` that contains the input parameters for an `Operation`\n    * Defines the expected `Output` for an `Operation`\n    * Accessors are write-only\n    * e.g. `DynamoDb\\PutItemInput`, `S3\\ListObjectRequest`\n* `Output`\n    * A `Shape` that contains the result of an `Operation`\n    * Extends `\\Aws\\Result`\n    * Accessors are read-only\n    * e.g. `DynamoDb\\PutItemOutput`, `S3\\ListObjectOutput`\n* `Client`\n    * Extends the corresponding SDK client\n    * Marshals an `Input` to the SDK `Operation` and returns the `Output`\n    * e.g. `S3\\S3Client`, `DynamoDb\\DynamoDbClient`\n    \n## Issues / Quriks\n\n* Paginators are not implemented\n* CommandPools are not implemented\n* `\\Aws\\Result::$data` is passed by value to `Output` classes\n* `_` will be appended the PHP class name when:\n    * A service contains two types with identical case-insensitive names\n    * A type is a PHP keyword\n* Some service names are oddly named vs the namespace: e.g. `streams.dynamodb =\u003e DynamoDbStreams`\n* Some `Input` classes use the term `Request` instead of `Input` per the SDK metadata\n\n### Acknowledgements\n* Inspired by [goetas-webeservices/xsd2php](https://github.com/goetas-webservices/xsd2php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtek%2Faws-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtek%2Faws-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtek%2Faws-gen/lists"}