{"id":14986036,"url":"https://github.com/maxbeckers/google-actions-php","last_synced_at":"2025-04-11T20:32:23.061Z","repository":{"id":62525554,"uuid":"99607085","full_name":"maxbeckers/google-actions-php","owner":"maxbeckers","description":"This library is a helper for google actions / google home apps with php.","archived":false,"fork":false,"pushed_at":"2023-05-25T08:19:43.000Z","size":24,"stargazers_count":22,"open_issues_count":4,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-26T10:03:12.569Z","etag":null,"topics":["actions","google","google-actions","google-actions-php","google-home","google-home-php","home","php","php7"],"latest_commit_sha":null,"homepage":"","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/maxbeckers.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-07T18:22:52.000Z","updated_at":"2023-11-07T12:46:17.000Z","dependencies_parsed_at":"2024-09-11T19:52:45.427Z","dependency_job_id":"f2ad6602-ce7c-4347-8eb8-5a938391871f","html_url":"https://github.com/maxbeckers/google-actions-php","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":"0.19999999999999996","last_synced_commit":"a38cd36e3f4ef45f5aaccd6ec5ac8a95648607d4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeckers%2Fgoogle-actions-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeckers%2Fgoogle-actions-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeckers%2Fgoogle-actions-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeckers%2Fgoogle-actions-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbeckers","download_url":"https://codeload.github.com/maxbeckers/google-actions-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248476472,"owners_count":21110291,"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":["actions","google","google-actions","google-actions-php","google-home","google-home-php","home","php","php7"],"created_at":"2024-09-24T14:12:10.728Z","updated_at":"2025-04-11T20:32:18.034Z","avatar_url":"https://github.com/maxbeckers.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google actions php library\nThis library is a helper for google actions with php.\n\n## Install via composer\nRequire the package with composer:\n```\ncomposer require maxbeckers/google-actions-php\n```\n\n## Usage\nHandle the request: \n- map request data to request object\n- validate request\n- handle request data\n- create response\n- send response\n\n### Map request data to request object\nMap needed request headers and request body to `Request`.\n```php\nuse MaxBeckers\\GoogleActions\\Request\\Request;\n...\n$requestBody  = file_get_contents('php://input');\n$googleRequest = Request::fromGoogleRequest($requestBody);\n```\n### Validate request\nThe `RequestValidator` will handle the google request validation.\n```php\nuse MaxBeckers\\GoogleActions\\Validation\\RequestValidator;\n...\n$validator = new RequestValidator();\n$validator-\u003evalidate($googleRequest);\n```\n### Register request handlers\nFor different requests it's helpful to create different RequestHandlers.\n```php\nuse MaxBeckers\\GoogleActions\\RequestHandler\\RequestHandlerRegistry;\n...\n$requestHandlerRegistry = new RequestHandlerRegistry();\n$requestHandlerRegistry-\u003eaddHandler($myRequestHandler);\n```\n### Use registry to handle request\n```php\nuse MaxBeckers\\GoogleActions\\RequestHandler\\RequestHandlerRegistry;\n...\n$requestHandler = $requestHandlerRegistry-\u003egetSupportingHandler($googleRequest);\n$response       = $requestHandler-\u003ehandleRequest($googleRequest);\n```\n### Render response\n```php\nheader('Content-Type: application/json');\necho json_encode($response);\nexit();\n```\n### Create a new request handler\nThe new request handler must extend `AbstractRequestHandler`.\nFirst implement the abstract `supportsRequest`-method.\n```php\npublic function supportsRequest(Request $request): bool\n{\n    return true; // check request data\n}\n```\nThen implement the `handleRequest`-method. For simple responses there is a `ResponseHelper`.\n```php\nuse MaxBeckers\\GoogleActions\\Helper\\ResponseHelper;\n...\n/** @var ResponseHelper */\nprivate $responseHelper;\n...\npublic function handleRequest(Request $request): Response\n{\n    // todo set needed response data\n    return $responseHelper-\u003erespond('Success :)');\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeckers%2Fgoogle-actions-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbeckers%2Fgoogle-actions-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeckers%2Fgoogle-actions-php/lists"}