{"id":21557757,"url":"https://github.com/madewithlove/htaccess-api-client","last_synced_at":"2025-04-10T10:34:17.925Z","repository":{"id":36275544,"uuid":"222961708","full_name":"madewithlove/htaccess-api-client","owner":"madewithlove","description":"API client for the best htaccess tester in the world","archived":false,"fork":false,"pushed_at":"2024-07-10T03:12:39.000Z","size":212,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-24T09:21:38.606Z","etag":null,"topics":["hacktoberfest","php"],"latest_commit_sha":null,"homepage":"https://htaccess.madewithlove.be/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madewithlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["madewithlove"]}},"created_at":"2019-11-20T14:55:17.000Z","updated_at":"2024-07-17T10:02:08.000Z","dependencies_parsed_at":"2022-09-04T12:21:21.043Z","dependency_job_id":null,"html_url":"https://github.com/madewithlove/htaccess-api-client","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madewithlove%2Fhtaccess-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madewithlove%2Fhtaccess-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madewithlove%2Fhtaccess-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madewithlove%2Fhtaccess-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madewithlove","download_url":"https://codeload.github.com/madewithlove/htaccess-api-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199245,"owners_count":21063641,"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":["hacktoberfest","php"],"created_at":"2024-11-24T08:13:06.878Z","updated_at":"2025-04-10T10:34:17.898Z","avatar_url":"https://github.com/madewithlove.png","language":"PHP","funding_links":["https://github.com/sponsors/madewithlove"],"categories":[],"sub_categories":[],"readme":"# htaccess-api-client\n\n[![Build status](https://github.com/madewithlove/htaccess-api-client/workflows/Continious%20Integration/badge.svg)](https://github.com/madewithlove/htaccess-api-client/actions?query=branch%3Amain)\n[![Latest Stable Version](https://poser.pugx.org/madewithlove/htaccess-api-client/version)](https://packagist.org/packages/madewithlove/htaccess-api-client)\n[![License](https://poser.pugx.org/madewithlove/htaccess-api-client/license)](https://packagist.org/packages/madewithlove/htaccess-api-client)\n[![codecov](https://codecov.io/gh/madewithlove/htaccess-api-client/branch/main/graph/badge.svg)](https://codecov.io/gh/madewithlove/htaccess-api-client)\n\nThis is an API client to interact with the [Htaccess tester](https://htaccess.madewithlove.com/).\n\n### Installation\n\n```bash\ncomposer require madewithlove/htaccess-api-client\n```\n\n### Usage\n\nThe package can be used with every PSR-compatible http client. In this example, we're going to be using\nguzzle's PSR adapter.\n\n```php\nuse Http\\Factory\\Guzzle\\ServerRequestFactory;\nuse Http\\Adapter\\Guzzle6\\Client;\nuse Madewithlove\\HtaccessClient\n\n$client = new HtaccessClient(\n    new Client(),\n    new ServerRequestFactory()\n);\n\n$response = $client-\u003etest(\n    'http://localhost',\n    'RewriteRule .* /foo [R]'\n);\n\n$response-\u003egetOutputUrl(); // \"http://localhost/foo\"\n$response-\u003egetLines();\n/*\narray(1) {\n  [0]=\u003e\n  object(Madewithlove\\ResultLine)#30 (5) {\n    [\"line\":\"Madewithlove\\ResultLine\":private]=\u003e string(23) \"RewriteRule .* /foo [R]\"\n    [\"message\":\"Madewithlove\\ResultLine\":private]=\u003e string(98) \"The new url is http://localhost/foo\nTest are stopped, a redirect will be made with status code 302\"\n    [\"isMet\":\"Madewithlove\\ResultLine\":private]=\u003e bool(true)\n    [\"isValid\":\"Madewithlove\\ResultLine\":private]=\u003e bool(true)\n    [\"wasReached\":\"Madewithlove\\ResultLine\":private]=\u003e bool(true)\n  }\n}\n*/\n```\n\n### Server variables\n\nHtaccess Tester supports passing server variables to be evaluated by the rewrite rules.\nWe currently support the following variables.\n\nServer variables can be passed to the `test()` and `share()` methods.\n```php\n$serverVariables = ServerVariables::default()-\u003ewith(\n    'SERVER_NAME',\n    'example.com'\n);\n\n$response = $client-\u003etest(\n    'http://localhost',\n    'RewriteCond %{SERVER_NAME} example.com\n    RewriteRule .* /foo [R]',\n    $serverVariables\n);\n\n$response = $client-\u003eshare(\n    'http://localhost',\n    'RewriteCond %{SERVER_NAME} example.com\n    RewriteRule .* /foo [R]',\n    $serverVariables\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadewithlove%2Fhtaccess-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadewithlove%2Fhtaccess-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadewithlove%2Fhtaccess-api-client/lists"}