{"id":20388543,"url":"https://github.com/efureev/response-actions","last_synced_at":"2026-01-30T08:17:51.564Z","repository":{"id":153891009,"uuid":"630981085","full_name":"efureev/response-actions","owner":"efureev","description":"Single Action structure for HTTP-Response","archived":false,"fork":false,"pushed_at":"2024-12-05T12:53:53.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-06T09:06:29.425Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efureev.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"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}},"created_at":"2023-04-21T16:01:31.000Z","updated_at":"2024-12-05T11:52:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"f559bfa5-1517-419b-942a-486bc386bb3a","html_url":"https://github.com/efureev/response-actions","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Fresponse-actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Fresponse-actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Fresponse-actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Fresponse-actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efureev","download_url":"https://codeload.github.com/efureev/response-actions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234015362,"owners_count":18766145,"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-15T03:11:22.043Z","updated_at":"2026-01-30T08:17:51.549Z","avatar_url":"https://github.com/efureev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Response Action\n\n![](https://img.shields.io/badge/php-8.4-blue.svg)\n[![PHP Package](https://github.com/efureev/response-actions/actions/workflows/php.yml/badge.svg)](https://github.com/efureev/response-actions/actions/workflows/php.yml)\n[![Build Status](https://travis-ci.org/efureev/response-actions.svg?branch=master)](https://travis-ci.org/efureev/response-actions)\n[![Latest Stable Version](https://poser.pugx.org/efureev/response-actions/v/stable?format=flat)](https://packagist.org/packages/efureev/response-actions)\n[![Maintainability](https://qlty.sh/gh/efureev/projects/response-actions/maintainability.svg)](https://qlty.sh/gh/efureev/projects/response-actions)\n[![Code Coverage](https://qlty.sh/gh/efureev/projects/response-actions/coverage.svg)](https://qlty.sh/gh/efureev/projects/response-actions)\n[![codecov](https://codecov.io/github/efureev/response-actions/graph/badge.svg?token=ftgNXhJUxk)](https://codecov.io/github/efureev/response-actions)\n\n## Install\n\nFor php \u003e= 8.4\n\n```bash\ncomposer require efureev/response-actions \"^2.0\"\n```\n\n## Action Message Response Structure\n\n```json5\n{\n  // Action Message block (can be overwritten with a custom key)\n  \"_responseAction\": {\n    // Request Execution Status. See: ResponseActions\\\\StatusEnum\n    \"status\": \"success\",\n    // list of actions: array of ResponseActions\\\\Actions\\\\Action\n    \"actions\": [\n      {\n        // ... some action's body\n      }\n    ],\n    // optional extra payload attached to the response action\n    \"extra\": { }\n  }\n}\n```\n\n### Actions\n\n- Message\n- Command\n- Download\n- Event\n- Redirect\n\n#### Common Action's Props\n\n```json5\n{\n  // Action's Name\n  \"name\": \"message\",\n  // Action order to perform. Default = 0\n  \"order\": 1,\n  // Private action. boolean true or string channel name\n  \"private\": true\n}\n```\n\n#### Action Message\n\n```json5\n{\n  // message to show to user\n  \"message\": \"It's done!\",\n  // Type of the message (optional when type is empty)\n  \"type\": \"info\"\n}\n```\n\n```php\nuse ResponseActions\\ResponseAction;\nuse ResponseActions\\Actions\\Message;\n\nResponseAction::successMessage('Operation has success!');\n\n// Multi-message with different types\nResponseAction::errorMessage('Operation has failed!')\n    -\u003eaddAction(Message::info('Try to restart page'));\n```\n\n#### Action Command\n\n```json5\n{\n  // pending | done | failed\n  \"status\": \"failed\",\n  // optional description\n  \"description\": \"Reason...\"\n}\n```\n\nHelpers:\n- ResponseAction::cmd()     // pending\n- ResponseAction::cmdDone() // done\n- ResponseAction::cmdFailed() // failed\n\n#### Action Download\n\n```json5\n{\n  \"url\": \"https://example.com/file.pdf\",\n  \"file\": \"Readme.pdf\",\n  // optional params passed to the client handler\n  \"params\": {}\n}\n```\n\n#### Action Event\n\n```json5\n{\n  \"event\": \"uploadData\",\n  \"params\": {}\n}\n```\n\n#### Action Redirect\n\n```json5\n{\n  \"url\": \"https://example.com\",\n  \"target\": \"_blank\",\n  // native | router\n  \"type\": \"native\",\n  // HTTP code (when applicable)\n  \"code\": 302\n}\n```\n\nYou can also use helpers:\n- ResponseAction::redirect('https://example.com')\n- ResponseActions\\\\Actions\\\\Redirect::router('/route')\n- ResponseActions\\\\Actions\\\\Redirect::native('https://example.com')\n\n### Private\n\nYou can use private props and order:\n\n```php\nuse ResponseActions\\ResponseAction;\nuse ResponseActions\\Actions\\{Event, Redirect, Download};\n\n$responseAction = ResponseAction::successMessage('Operation has done!')\n    -\u003eaddAction(\n        new Event('log', ['saved!', 'continue watching...']),\n        (new Event('uploadModuleData'))-\u003eprivate(),\n        (new Event('uploadData'))-\u003eprivate('menu'),\n        (new Event('refreshUser'))-\u003eprivate('authUser')-\u003ewithOrder(1),\n        (new Redirect('https://example.com'))-\u003ewithOrder(5),\n        (new Download('https://example.com/file.pdf', 'Readme.pdf'))-\u003ewithOrder(2),\n    );\n```\n\n### ExtraData\n\nYou can attach extra data to the whole ResponseAction or to Message actions:\n\n```php\nuse ResponseActions\\ResponseAction;\n\n$responseAction = ResponseAction::cmdDone()\n    -\u003ewithExtra(['any' =\u003e 'thing']);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Fresponse-actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefureev%2Fresponse-actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Fresponse-actions/lists"}