{"id":18285502,"url":"https://github.com/bemit/php-service-dynamodb","last_synced_at":"2025-04-09T06:16:56.336Z","repository":{"id":56950675,"uuid":"422624379","full_name":"bemit/php-service-dynamodb","owner":"bemit","description":"Custom DynamoDB service for PHP.","archived":false,"fork":false,"pushed_at":"2021-11-04T09:51:53.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T00:33:01.407Z","etag":null,"topics":[],"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/bemit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-29T15:24:28.000Z","updated_at":"2021-11-04T09:45:41.000Z","dependencies_parsed_at":"2022-08-21T08:20:59.667Z","dependency_job_id":null,"html_url":"https://github.com/bemit/php-service-dynamodb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemit%2Fphp-service-dynamodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemit%2Fphp-service-dynamodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemit%2Fphp-service-dynamodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemit%2Fphp-service-dynamodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bemit","download_url":"https://codeload.github.com/bemit/php-service-dynamodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"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":[],"created_at":"2024-11-05T13:16:52.969Z","updated_at":"2025-04-09T06:16:56.316Z","avatar_url":"https://github.com/bemit.png","language":"PHP","readme":"# PHP DynamoDB Service\n\n[![Latest Stable Version](https://poser.pugx.org/bemit/dynamodb/version.svg)](https://packagist.org/packages/bemit/dynamodb)\n[![Latest Unstable Version](https://poser.pugx.org/bemit/dynamodb/v/unstable.svg)](https://packagist.org/packages/bemit/dynamodb)\n[![codecov](https://codecov.io/gh/bemit/php-service-dynamodb/branch/master/graph/badge.svg?token=D80MD3SR7Q)](https://codecov.io/gh/bemit/php-service-dynamodb)\n[![Total Downloads](https://poser.pugx.org/bemit/dynamodb/downloads.svg)](https://packagist.org/packages/bemit/dynamodb)\n[![Github actions Build](https://github.com/bemit/php-service-dynamodb/actions/workflows/blank.yml/badge.svg)](https://github.com/bemit/php-service-dynamodb/actions)\n[![PHP Version Require](http://poser.pugx.org/bemit/dynamodb/require/php)](https://packagist.org/packages/bemit/dynamodb)\n\nPHP DynamoDB service class, with item \u003c\u003e data converters.\n\n```shell\ncomposer require bemit/dynamodb\n```\n\nUsage:\n\n```php\nuse Bemit\\DynamoDB\\DynamoService;\n\n$service = new DynamoService(\n    string $region,\n    string $dynamo_key, string $dynamo_secret,\n    ?string $endpoint = null,\n    $debug = false,\n    // optional, overwrite the converters:\n    ConvertFromItemInterface $from_item = null,\n    ConvertToItemInterface $to_item = null,\n);\n\n// just the dynamodb client:\n$client = $service-\u003eclient();\n\n//\n// Convert from array / stdClass to DynamoDB Item:\n\n// $arr = ['some_key' =\u003e 'the-text']\n$item = $service-\u003etoItem($arr);\n\n// or as stdClass:\n// $std = new stdClass;\n// $std-\u003esome_key = 'the-text';\n$item = $service-\u003etoItem($std);\n\n// single value:\n// $arr_e = 'the-text'\n$item_p = $service-\u003etoItemValue($arr_e);\n\n//\n// Convert from DynamoDB Item to array / stdClass:\n\n// $item = ['some_key' =\u003e ['S' =\u003e 'the-text']]\n$arr = $service-\u003efromItem($item);\n// $item_p = ['S' =\u003e 'the-text']]\n$arr_p = $service-\u003efromItemValue($item_p);\n\n//\n// Convert NS/SS from array / stdClass to DynamoDB:\n//\n// NS + SS needs a \"key schema\" when converting from array to item,\n// nested usages of NS/SS are not automated and would result in a `L` the next save\n\n// $arr_ss = ['s1', 's2', 's3']\n$item_ss = $service-\u003etoItemValue($arr_ss, 'SS');\n// $arr_ns = [1, 2, 3]\n$item_ns = $service-\u003etoItemValue($arr_ns, 'NS');\n\n// or:\n// $obj = ['prop1' =\u003e ['s1', 's2', 's3']]\n$item_obj = $service-\u003etoItem($obj, ['prop1' =\u003e 'SS']);\n\n// \n// Ignore Nulls using when converting from array / stdClass to DynamoDB\n\n// `true` as  third parameter of `toItem` will ignore null values in the root level of the item \n// $arr = ['k1' =\u003e 's1', 'k2' =\u003e null]\n$item = $service-\u003etoItem($arr, [], true);\n```\n\nModes supported, with automatic detection and conversion:\n\n- `S`, strings\n- `N`, numerics, cast by `(float)`, keeps numbers the same in e.g. JSON (no `.0`)\n- `BOOL`, booleans\n- `M`, maps, `stdClass` or assoc arrays\n    - for safest usage uses `stdClass` for `M` conversion\n    - for app-side, you should use e.g. non-assoc `json_decode`\n    - supports nested maps \u0026 lists\n- `L`, lists / arrays **or empty array**\n    - supports nested lists \u0026 maps\n- `NULL`, null values\n\nModes supported with typing at `toItem`, automatic at `fromItem`:\n\n- `SS`, string sets / list of strings\n- `NS`, string sets / list of strings\n\n## Dev Notices\n\nCommands to set up and run e.g. tests:\n\n```bash\n# on windows:\ndocker run -it --rm -v %cd%:/app composer install --ignore-platform-reqs\n\ndocker run -it --rm -v %cd%:/var/www/html php:8.1-rc-cli-alpine sh\n\ndocker run --rm -v %cd%:/var/www/html php:8.1-rc-cli-alpine sh -c \"cd /var/www/html \u0026\u0026 ./vendor/bin/phpunit --testdox -c phpunit-ci.xml\"\n\n#docker-compose run --rm test sh -c \"cd /var/www/html \u0026\u0026 composer update\"\ndocker-compose run --rm test sh\n\ncd /var/www/html \u0026\u0026 ./vendor/bin/phpunit --coverage-text --testdox -c phpunit-ci.xml\n\ncd /var/www/html \u0026\u0026 ./vendor/bin/phpunit --coverage-html coverage --testdox -c phpunit-ci.xml\n\n# on unix:\ndocker run -it --rm -v `pwd`:/app composer install\n\ndocker run -it --rm -v `pwd`:/var/www/html php:8.1-rc-cli-alpine sh\n\ndocker run --rm -v `pwd`:/var/www/html php:8.1-rc-cli-alpine sh -c \"cd /var/www/html \u0026\u0026 ./vendor/bin/phpunit --testdox -c phpunit-ci.xml\"\n```\n\n## Versions\n\nThis project adheres to [semver](https://semver.org/), **until `1.0.0`** and beginning with `0.1.0`: all `0.x.0` releases are like MAJOR releases and all `0.0.x` like MINOR or PATCH, modules below `0.1.0` should be considered experimental.\n\n## License\n\nThis project is free software distributed under the [**MIT LICENSE**](LICENSE).\n\n\u003e Amazon DynamoDB® is a trademark of Amazon.com, Inc. No endorsements by Amazon.com, Inc. are implied by the use of these marks.\n\n### Contributors\n\nBy committing your code to the code repository you agree to release the code under the MIT License attached to the repository.\n\n***\n\nMaintained by [Michael Becker](https://mlbr.xyz)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemit%2Fphp-service-dynamodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbemit%2Fphp-service-dynamodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemit%2Fphp-service-dynamodb/lists"}