{"id":23879542,"url":"https://github.com/ohseesoftware/caddy-config-php","last_synced_at":"2025-04-09T17:45:12.800Z","repository":{"id":36460914,"uuid":"225050244","full_name":"ohseesoftware/caddy-config-php","owner":"ohseesoftware","description":"Caddy v2 API wrapper for PHP.","archived":false,"fork":false,"pushed_at":"2023-04-19T19:24:56.000Z","size":66,"stargazers_count":11,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T19:51:21.424Z","etag":null,"topics":["api","caddy","php","wrapper"],"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/ohseesoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-30T17:59:11.000Z","updated_at":"2024-03-15T09:36:50.000Z","dependencies_parsed_at":"2023-01-17T01:40:44.380Z","dependency_job_id":null,"html_url":"https://github.com/ohseesoftware/caddy-config-php","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/ohseesoftware%2Fcaddy-config-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Fcaddy-config-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Fcaddy-config-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohseesoftware%2Fcaddy-config-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohseesoftware","download_url":"https://codeload.github.com/ohseesoftware/caddy-config-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248080764,"owners_count":21044555,"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":["api","caddy","php","wrapper"],"created_at":"2025-01-03T23:17:55.845Z","updated_at":"2025-04-09T17:45:12.766Z","avatar_url":"https://github.com/ohseesoftware.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Caddy Config PHP\nCaddy v2 API helper for PHP.\n\n[![Current Release](https://img.shields.io/github/release/ohseesoftware/caddy-config-php.svg?style=flat-square)](https://github.com/ohseesoftware/caddy-config-php/releases)\n![Build Status Badge](https://github.com/ohseesoftware/caddy-config-php/workflows/Build/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/ohseesoftware/caddy-config-php/badge.svg?branch=master)](https://coveralls.io/github/ohseesoftware/caddy-config-php?branch=master)\n[![Maintainability Score](https://img.shields.io/codeclimate/maintainability/ohseesoftware/caddy-config-php.svg?style=flat-square)](https://codeclimate.com/github/ohseesoftware/caddy-config-php)\n[![Downloads](https://img.shields.io/packagist/dt/ohseesoftware/caddy-config-php.svg?style=flat-square)](https://packagist.org/packages/ohseesoftware/caddy-config-php)\n[![MIT License](https://img.shields.io/github/license/ohseesoftware/caddy-config-php.svg?style=flat-square)](https://github.com/ohseesoftware/caddy-config-php/blob/master/LICENSE)\n\n---\n\nCaddy v2 allows you to update your Caddy configuration via a JSON API. This package is a simple helper library to update parts of your configuration.\n\nFunctionality for updating all aspects of the configuration will be added over time.\n\n## Usage\n\nTo get started, create an instance of `OhSeeSoftware\\CaddyConfig\\Client`, ensuring to pass your Caddy network address as the first argument:\n\n```php\n$client = new OhSeeSoftware\\CaddyConfig\\Client('localhost:2019');\n```\n\nFrom there, you can use the `$client` instance to make API requests to your Caddy instance.\n\nThe idea behind the wrapper is that you can have a `Client` singleton class, and then use the `$client-\u003erequest()` method to create new `Request` instances. You should create a new `Request` instance per HTTP request you send to your Caddy server.\n\n## API Methods\n\n### Client\n\n**__constructor()**\n\nCreates a new instance of the `Client` class.\n\nArguments:\n\n* `$caddyHost` - _string_: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.\n\n**setCaddyHost()**\n\nAllows you to change the Caddy host after creating the Client instance.\n\nArguments:\n\n* `$caddyHost` - _string_: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.\n\n**request()**\n\nReturns a new `Request` instance which you use to make configuration requests.\n\nNo arguments.\n\n### Request\n\nUse the `Request` class to compose your request to send to Caddy. Here's an example of how you can add a new host to a server:\n\n```php\n$client = new OhSeeSoftware\\CaddyConfig\\Client('localhost:2019');\n$client-\u003erequest()\n  -\u003ehttp()\n  -\u003eserver('srv0')\n  -\u003eroute(0)\n  -\u003ematch(0)\n  -\u003eaddHost('example.com');\n```\n\n**__constructor()**\n\nCreates a new instance of the `Request` class.\n\nArguments:\n\n* `$caddyHost` - _string_: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.\n\n**addHost()**\n\nSends a request to Caddy to add the given host.\n\nArguments:\n\n* `$host` - _string_: The host to add.\n\nReturns:\n\n* `Response` - The response from Caddy wrapped in a `Response` instance.\n\n**http()**\n\nAdds the http path, \"/apps/http\", to the request URI.\n\nNo arguments.\n\nReturns:\n\n* `Request` - The request instance (allows chaining).\n\n**server()**\n\nAdds the server path, \"/servers/{server}\", to the request URI.\n\nArguments:\n\n* `$server` - _string_: The name of the server to target.\n\nReturns:\n\n* `Request` - The request instance (allows chaining).\n\n**route()**\n\nAdds the route path, \"/routes/{routeIndex}\", to the request URI.\n\nArguments:\n\n* `$routeIndex` - _int_: The route to target.\n\nReturns:\n\n* `Request` - The request instance (allows chaining).\n\n**match()**\n\nAdds the match path, \"/match/{matchIndex}\", to the request URI.\n\nArguments:\n\n* `$matchIndex` - _int_: The match to target.\n\nReturns:\n\n* `Request` - The request instance (allows chaining).\n\n**sendRequest()**\n\nSends the built request to the Caddy server.\n\nArguments:\n\n* `$method` - _string_: The method for the request.\n* `$body` - _array|nuullable_: The request body to send to Caddy.\n\nReturns:\n\n* `Response` - A new instance of a `Response` instance.\n\n### Response\n\n**__constructor()**\n\nCreates a new instance of the `Response` class.\n\nArguments:\n\n* `$response` - _ResponseInterface_: Instance of a `ResponseInterface` (created by Guzzle).\n\n**getBody()**\n\nReturns the response body as a string.\n\nNo arguments.\n\n**isSuccessful()**\n\nReturns a boolean indicating if the request was successful. Status codes of 200 or 201 are considered successful, everything else is not.\n\nNo arguments.\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/ohseesoftware/caddy-config-php/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohseesoftware%2Fcaddy-config-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohseesoftware%2Fcaddy-config-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohseesoftware%2Fcaddy-config-php/lists"}