{"id":18794567,"url":"https://github.com/effectra/http-extensions","last_synced_at":"2025-12-29T18:30:15.580Z","repository":{"id":177372861,"uuid":"655415953","full_name":"effectra/http-extensions","owner":"effectra","description":"Effectra\\Http\\Extensions is a PHP package that provides extensions and utilities for working with HTTP requests and responses.","archived":false,"fork":false,"pushed_at":"2024-01-02T18:52:19.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-29T16:34:08.405Z","etag":null,"topics":["extensions","php","psr","psr-7","requests","response","stream","uri"],"latest_commit_sha":null,"homepage":"","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/effectra.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-06-18T20:29:17.000Z","updated_at":"2023-06-18T20:34:35.000Z","dependencies_parsed_at":"2023-12-01T10:23:55.301Z","dependency_job_id":"6d768c14-bdd2-49a6-a4be-3389ade54cf0","html_url":"https://github.com/effectra/http-extensions","commit_stats":null,"previous_names":["effectra/http-extensions"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fhttp-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/http-extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718704,"owners_count":19685799,"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":["extensions","php","psr","psr-7","requests","response","stream","uri"],"created_at":"2024-11-07T21:29:48.342Z","updated_at":"2025-12-29T18:30:15.492Z","avatar_url":"https://github.com/effectra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Effectra\\Http\\Extensions\n\nEffectra\\Http\\Extensions is a PHP package that provides extensions and utilities for working with HTTP requests and responses.\n\n## Installation\n\nYou can install this package via Composer. Run the following command in your project directory:\n\n```bash\ncomposer require effectra/http-extensions\n```\n\n## Usage\n\n### RequestExtension\n\nThe `RequestExtension` class extends the `Effectra\\Http\\Message\\ServerRequest` class and provides additional methods for working with HTTP requests.\n\n#### Creating a Request\n\nYou can create a new request using the `RequestExtension::fromGlobal()` method, which creates a request object based on the global variables:\n\n```php\n$request = RequestExtension::fromGlobal();\n```\n\n#### Retrieving Request Information\n\n- `RequestExtension::url()`: Returns the URL of the request.\n- `RequestExtension::method()`: Returns the HTTP method of the request.\n- `RequestExtension::path()`: Returns the path of the request URI.\n- `RequestExtension::inputs()`: Returns an object containing all input data from the request.\n- `RequestExtension::input(string $input)`: Returns the value of a specific input parameter.\n- `RequestExtension::validateInputs()`: Validates the input data using a third-party validation library.\n- `RequestExtension::onlyInputs(array $inputs)`: Returns an object containing only the input data for the specified input keys.\n- `RequestExtension::data(bool $associative = false)`: Returns the input data as an array or object.\n- `RequestExtension::getTokenFromBearer()`: Extracts the token from the \"Authorization\" header (Bearer authentication).\n\n### UriExtension\n\nThe `UriExtension` class extends the `Effectra\\Http\\Message\\Uri` class and provides additional methods for working with URIs.\n\n#### Modifying Queries\n\n- `UriExtension::withQueries(array $queries)`: Returns a new URI object with the specified query parameters.\n\n### ResponseExtension\n\nThe `ResponseExtension` class extends the `Effectra\\Http\\Message\\Response` class and provides additional methods for working with HTTP responses.\n\n#### Creating a JSON Response\n\n- `ResponseExtension::json($data, int $status_code = 200, array $headers = [])`: Creates a JSON response with the specified data, status code, and additional headers.\n\n#### Converting Response Body to Array\n\n- `ResponseExtension::jsonToArray(?bool $associative = null, int $depth = 512, int $flags = 0)`: Converts the response body from JSON to an associative array.\n\n#### File Attachment\n\n- `ResponseExtension::attachFile(string $filePath, ?string $filename = null, ?string $contentType = null)`: Creates a response with a file attachment.\n\n#### Setting Cookies\n\n- `ResponseExtension::withCookie(string $name, string $value, int $expires = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httpOnly = true)`: Sets a cookie with the given parameters.\n- `ResponseExtension::withCookies(array $cookies, int $expires = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httpOnly = true)`: Sets multiple cookies with the given parameters.\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.\n\n## License\n\nThis package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n\n## Credits\n\nEffectra\\Http\\Extensions is developed and maintained by [Mohammed Taha](https://github.com/BmtMohammedTaha).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fhttp-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fhttp-extensions/lists"}