{"id":17689416,"url":"https://github.com/m1guelpf/laravel-multiformat","last_synced_at":"2025-09-01T01:04:34.788Z","repository":{"id":57015879,"uuid":"121867678","full_name":"m1guelpf/laravel-multiformat","owner":"m1guelpf","description":"Multiformat Endpoints in Laravel","archived":false,"fork":false,"pushed_at":"2020-10-22T21:19:47.000Z","size":11,"stargazers_count":40,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-06T02:22:15.599Z","etag":null,"topics":["endpoint","laravel","laravel-package","multiformats","package"],"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/m1guelpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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-02-17T15:44:59.000Z","updated_at":"2025-07-16T10:37:42.000Z","dependencies_parsed_at":"2022-08-22T09:31:47.285Z","dependency_job_id":null,"html_url":"https://github.com/m1guelpf/laravel-multiformat","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/m1guelpf/laravel-multiformat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flaravel-multiformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flaravel-multiformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flaravel-multiformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flaravel-multiformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1guelpf","download_url":"https://codeload.github.com/m1guelpf/laravel-multiformat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flaravel-multiformat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273061066,"owners_count":25038596,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"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":["endpoint","laravel","laravel-package","multiformats","package"],"created_at":"2024-10-24T11:47:43.593Z","updated_at":"2025-09-01T01:04:34.755Z","avatar_url":"https://github.com/m1guelpf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiformat Endpoints in Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/m1guelpf/laravel-multiformat.svg?style=flat-square)](https://packagist.org/packages/m1guelpf/laravel-multiformat)\n[![Total Downloads](https://img.shields.io/packagist/dt/m1guelpf/laravel-multiformat.svg?style=flat-square)](https://packagist.org/packages/m1guelpf/laravel-multiformat)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require m1guelpf/laravel-multiformat\n```\n\n## Usage\n\n``` php\n\u003c?php\n\n/**\n * Mark a route as 'multiformat' to allow different extensions (html, json, xml, etc.)\n *\n * This route will match all of these requests:\n *     /podcasts/4\n *     /podcasts/4.json\n *     /podcasts/4.html\n *     /podcasts/4.zip\n */\nRoute::get('/podcasts/{id}', 'PodcastsController@show')-\u003emultiformat();\n\n/**\n * Use `Request::match()` to return the right response for the requested format.\n *\n * Supports closures to avoid doing unnecessary work, and returns 404 if the\n * requested format is not supported.\n *\n * Will also take into account the `Accept` header if no extension is provided.\n */\nclass PodcastsController\n{\n    public function show($id)\n    {\n        $podcast = Podcast::findOrFail($id);\n        \n        return request()-\u003ematch([\n            'html' =\u003e view('podcasts.show', [\n                'podcast' =\u003e $podcast,\n                'episodes' =\u003e $podcast-\u003erecentEpisodes(5),\n            ]),\n            'json' =\u003e $podcast,\n            'xml' =\u003e function () use ($podcast) {\n                return response($podcast-\u003etoXml(), 200, ['Content-Type' =\u003e 'text/xml']);\n            }\n        ]);\n    }\n}\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email soy@miguelpiedrafita.com instead of using the issue tracker.\n\n## Credits\n\n- [Adam Wathan](https://github.com/adamwathan) for the [original gist](https://gist.github.com/adamwathan/984914b2eee8e4d79a06f7045e4ce999)\n- [Miguel Piedrafita](https://github.com/m1guelpf)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Flaravel-multiformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1guelpf%2Flaravel-multiformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Flaravel-multiformat/lists"}