{"id":22147547,"url":"https://github.com/myerscode/laravel-sub-request","last_synced_at":"2026-04-02T14:21:06.124Z","repository":{"id":57022616,"uuid":"105944122","full_name":"myerscode/laravel-sub-request","owner":"myerscode","description":"A helper and facade for making internal API sub requests to your application","archived":false,"fork":false,"pushed_at":"2026-03-24T11:47:30.000Z","size":44,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-25T14:55:47.816Z","etag":null,"topics":["facade","helper","laravel","sub-request"],"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/myerscode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-10-05T21:52:27.000Z","updated_at":"2026-03-24T11:46:43.000Z","dependencies_parsed_at":"2022-08-23T13:50:53.853Z","dependency_job_id":null,"html_url":"https://github.com/myerscode/laravel-sub-request","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/myerscode/laravel-sub-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-sub-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-sub-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-sub-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-sub-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myerscode","download_url":"https://codeload.github.com/myerscode/laravel-sub-request/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Flaravel-sub-request/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31307782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["facade","helper","laravel","sub-request"],"created_at":"2024-12-01T23:18:20.893Z","updated_at":"2026-04-02T14:21:06.116Z","avatar_url":"https://github.com/myerscode.png","language":"PHP","readme":"# Laravel Sub Request\n\nA helper and facade for making internal sub requests to your application API.\n\n[![Latest Stable Version](https://poser.pugx.org/myerscode/laravel-sub-request/v/stable)](https://packagist.org/packages/myerscode/laravel-sub-request)\n[![Total Downloads](https://poser.pugx.org/myerscode/laravel-sub-request/downloads)](https://packagist.org/packages/myerscode/laravel-sub-request)\n[![PHP Version Require](http://poser.pugx.org/myerscode/laravel-sub-request/require/php)](https://packagist.org/packages/myerscode/laravel-sub-request)\n[![License](https://poser.pugx.org/myerscode/laravel-sub-request/license)](https://github.com/myerscode/laravel-sub-request/blob/main/LICENSE)\n[![Tests](https://github.com/myerscode/laravel-sub-request/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/myerscode/laravel-sub-request/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/myerscode/laravel-sub-request/graph/badge.svg)](https://codecov.io/gh/myerscode/laravel-sub-request)\n\nBy sending a sub request within the application, you can consume your application's API without sending separate, slower HTTP requests.\n\n## Requirements\n\n- PHP 8.5+\n- Laravel 13.x\n\n## Install\n\n```bash\ncomposer require myerscode/laravel-sub-request\n```\n\nThe package will be auto-discovered by Laravel.\n\n## Usage\n\nYou can inject the `Dispatcher` into your class, use the `SubRequest` facade, or use the global `subrequest` helper.\n\n```php\nuse Myerscode\\Laravel\\SubRequest\\Dispatcher;\nuse Myerscode\\Laravel\\SubRequest\\SubRequest;\n\nclass MyController\n{\n    public function __construct(private readonly Dispatcher $subRequest) {}\n\n    // Using dependency injection\n    public function withInjection()\n    {\n        return $this-\u003esubRequest-\u003epost('/auth', ['foo' =\u003e 'bar']);\n    }\n\n    // Using the facade\n    public function withFacade()\n    {\n        return SubRequest::dispatch('GET', '/details', ['foo' =\u003e 'bar']);\n    }\n\n    // Using the helper\n    public function withHelper()\n    {\n        return subrequest('GET', '/details', ['foo' =\u003e 'bar']);\n    }\n}\n```\n\n### Available Methods\n\nThe `Dispatcher` provides shortcut methods for all HTTP verbs:\n\n```php\n$dispatcher-\u003eget('/url', $data);\n$dispatcher-\u003epost('/url', $data);\n$dispatcher-\u003eput('/url', $data);\n$dispatcher-\u003epatch('/url', $data);\n$dispatcher-\u003edelete('/url', $data);\n$dispatcher-\u003eoptions('/url', $data);\n```\n\n### Custom Headers\n\nAll methods accept an optional `$headers` array as the last parameter, allowing you to set custom headers on the sub request:\n\n```php\n// Set Authorization and Accept headers\n$dispatcher-\u003eget('/api/users', [], [\n    'Authorization' =\u003e 'Bearer my-token',\n    'Accept' =\u003e 'application/json',\n]);\n\n// Works with the facade and helper too\nSubRequest::dispatch('GET', '/api/users', [], ['Authorization' =\u003e 'Bearer my-token']);\nsubrequest('GET', '/api/users', [], ['Authorization' =\u003e 'Bearer my-token']);\n```\n\nHeaders are applied to the sub request and automatically restored to their original values after dispatch.\n\n### Cookies\n\nAll methods accept an optional `$cookies` array as the last parameter, allowing you to forward or set cookies on the sub request:\n\n```php\n// Set cookies on the sub request\n$dispatcher-\u003eget('/api/profile', [], [], [\n    'session_id' =\u003e 'abc123',\n    'token' =\u003e 'my-auth-token',\n]);\n\n// Combine headers and cookies\n$dispatcher-\u003epost('/api/data', ['key' =\u003e 'value'], [\n    'Accept' =\u003e 'application/json',\n], [\n    'session_id' =\u003e 'abc123',\n]);\n\n// Works with the facade and helper too\nSubRequest::dispatch('GET', '/api/profile', [], [], ['session_id' =\u003e 'abc123']);\nsubrequest('GET', '/api/profile', [], [], ['session_id' =\u003e 'abc123']);\n```\n\nCookies are applied to the sub request and automatically restored to their original values after dispatch.\n\n### Middleware Control\n\nUse `withoutMiddleware()` to skip specific middleware on a sub request:\n\n```php\nuse App\\Http\\Middleware\\Authenticate;\nuse App\\Http\\Middleware\\RateLimiter;\n\n// Skip a single middleware\n$dispatcher-\u003ewithoutMiddleware(Authenticate::class)-\u003eget('/api/internal');\n\n// Skip multiple middleware by chaining\n$dispatcher\n    -\u003ewithoutMiddleware(Authenticate::class)\n    -\u003ewithoutMiddleware(RateLimiter::class)\n    -\u003epost('/api/internal', $data);\n\n// Or pass an array\n$dispatcher-\u003ewithoutMiddleware([Authenticate::class, RateLimiter::class])-\u003eget('/api/internal');\n```\n\nThe middleware exclusion is automatically reset after each dispatch, so subsequent calls will run all middleware as normal.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Flaravel-sub-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyerscode%2Flaravel-sub-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Flaravel-sub-request/lists"}