{"id":22147544,"url":"https://github.com/myerscode/laravel-api-response","last_synced_at":"2025-07-26T02:31:55.645Z","repository":{"id":57022628,"uuid":"132524058","full_name":"myerscode/laravel-api-response","owner":"myerscode","description":"A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen","archived":false,"fork":false,"pushed_at":"2024-09-15T22:55:34.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-30T14:27:00.805Z","etag":null,"topics":["builder","fluent-helper","laravel","response"],"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/myerscode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2018-05-07T22:42:46.000Z","updated_at":"2024-09-15T22:55:37.000Z","dependencies_parsed_at":"2022-08-23T12:20:47.743Z","dependency_job_id":null,"html_url":"https://github.com/myerscode/laravel-api-response","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-api-response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-api-response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-api-response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-api-response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myerscode","download_url":"https://codeload.github.com/myerscode/laravel-api-response/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227443746,"owners_count":17776918,"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":["builder","fluent-helper","laravel","response"],"created_at":"2024-12-01T23:18:19.707Z","updated_at":"2024-12-01T23:18:20.265Z","avatar_url":"https://github.com/myerscode.png","language":"PHP","readme":"# Laravel API Response\n\u003e A fluent helper to provide a consistent shaped API responses in Laravel\n\n[![Latest Stable Version](https://poser.pugx.org/myerscode/laravel-api-response/v/stable)](https://packagist.org/packages/myerscode/laravel-api-response)\n[![Total Downloads](https://poser.pugx.org/myerscode/laravel-api-response/downloads)](https://packagist.org/packages/myerscode/laravel-api-response)\n[![License](https://poser.pugx.org/myerscode/laravel-api-response/license)](https://packagist.org/packages/myerscode/laravel-api-response)\n![Tests](https://github.com/myerscode/laravel-api-response/actions/workflows/tests.yml/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/myerscode/laravel-api-response/branch/main/graph/badge.svg?token=5ATH3Y8AX6)](https://codecov.io/gh/myerscode/laravel-api-response)\n## Why is this package helpful?\n\nThis package ensures your API will always return the same envelope shape, so consuming apps always know what to expect!\n\n## Install\n\nYou can install this package via composer:\n\n``` bash\ncomposer require myerscode/laravel-api-response\n```\n\n## Usage\n\nIn a Laravel controller you just to build up your response and return it! \n\nThe `api()` helper return a Response `Builder` and as it implements the [Responsable](https://laravel.com/api/master/Illuminate/Contracts/Support/Responsable.html) \ntrait you dont need to do anything more than return the builder\n\n### Using the api() helper function\n```php\nfunction resource()\n{\n    return api()-\u003estatus(201)-\u003edata(['name' =\u003e 'Foo Bar'])-\u003emessage('Record Created!');\n}\n```\n\n### Using a Builder class\n```php\n\nfunction resource() {\n    $buillder = new Builder();\n    $builder-\u003estatus(201)-\u003edata(['name' =\u003e 'Foo Bar'])-\u003emessage('Record Created!');\n    return $builder;\n}\n```\n\n\nWould return the following `JSON` response.\n\n```json\n{\n    \"status\": 201,\n    \"data\": {\n        \"name\": \"Foo Bar\"\n    },\n    \"meta\": [],\n    \"messages\": [\n        \"Record Created!\"\n    ]\n}\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Flaravel-api-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyerscode%2Flaravel-api-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Flaravel-api-response/lists"}