PHPackages                             ohseesoftware/caddy-config-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ohseesoftware/caddy-config-php

ActiveLibrary[API Development](/categories/api)

ohseesoftware/caddy-config-php
==============================

Caddy v2 API helper library.

v2.2.1(4y ago)111321[3 PRs](https://github.com/ohseesoftware/caddy-config-php/pulls)MITPHP

Since Dec 1Pushed 3y ago2 watchersCompare

[ Source](https://github.com/ohseesoftware/caddy-config-php)[ Packagist](https://packagist.org/packages/ohseesoftware/caddy-config-php)[ RSS](/packages/ohseesoftware-caddy-config-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)Dependencies (4)Versions (10)Used By (0)

Caddy Config PHP
================

[](#caddy-config-php)

Caddy v2 API helper for PHP.

[![Current Release](https://camo.githubusercontent.com/91a68a6a89c4721ad3346f0438fab610306fb942f800f302976d7d73ae28f68b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f68736565736f6674776172652f63616464792d636f6e6669672d7068702e7376673f7374796c653d666c61742d737175617265)](https://github.com/ohseesoftware/caddy-config-php/releases)[![Build Status Badge](https://github.com/ohseesoftware/caddy-config-php/workflows/Build/badge.svg)](https://github.com/ohseesoftware/caddy-config-php/workflows/Build/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/8a70de401555acca811fcd86f4a930e489ac123059041f81a796c86626fc4f9b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f68736565736f6674776172652f63616464792d636f6e6669672d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ohseesoftware/caddy-config-php?branch=master)[![Maintainability Score](https://camo.githubusercontent.com/665db4e1a91ccd068f027fa90e45d43f2903b46b718d1b024512215b4b91d250/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f6f68736565736f6674776172652f63616464792d636f6e6669672d7068702e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/ohseesoftware/caddy-config-php)[![Downloads](https://camo.githubusercontent.com/a68c1da45e5b77b139c44af55361edfde6aafdab7dcd2a753dffbb81c89da380/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f68736565736f6674776172652f63616464792d636f6e6669672d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ohseesoftware/caddy-config-php)[![MIT License](https://camo.githubusercontent.com/3396b71bb5de77fb59d71527ece2e2e353349fdad651a5e5415ab1da36e19360/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f68736565736f6674776172652f63616464792d636f6e6669672d7068702e7376673f7374796c653d666c61742d737175617265)](https://github.com/ohseesoftware/caddy-config-php/blob/master/LICENSE)

---

Caddy 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.

Functionality for updating all aspects of the configuration will be added over time.

Usage
-----

[](#usage)

To get started, create an instance of `OhSeeSoftware\CaddyConfig\Client`, ensuring to pass your Caddy network address as the first argument:

```
$client = new OhSeeSoftware\CaddyConfig\Client('localhost:2019');
```

From there, you can use the `$client` instance to make API requests to your Caddy instance.

The idea behind the wrapper is that you can have a `Client` singleton class, and then use the `$client->request()` method to create new `Request` instances. You should create a new `Request` instance per HTTP request you send to your Caddy server.

API Methods
-----------

[](#api-methods)

### Client

[](#client)

**\_\_constructor()**

Creates a new instance of the `Client` class.

Arguments:

- `$caddyHost` - *string*: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.

**setCaddyHost()**

Allows you to change the Caddy host after creating the Client instance.

Arguments:

- `$caddyHost` - *string*: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.

**request()**

Returns a new `Request` instance which you use to make configuration requests.

No arguments.

### Request

[](#request)

Use 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:

```
$client = new OhSeeSoftware\CaddyConfig\Client('localhost:2019');
$client->request()
  ->http()
  ->server('srv0')
  ->route(0)
  ->match(0)
  ->addHost('example.com');
```

**\_\_constructor()**

Creates a new instance of the `Request` class.

Arguments:

- `$caddyHost` - *string*: The address where the [Caddy config endpoint](https://github.com/caddyserver/caddy/wiki/v2:-Documentation#admin) is listening.

**addHost()**

Sends a request to Caddy to add the given host.

Arguments:

- `$host` - *string*: The host to add.

Returns:

- `Response` - The response from Caddy wrapped in a `Response` instance.

**http()**

Adds the http path, "/apps/http", to the request URI.

No arguments.

Returns:

- `Request` - The request instance (allows chaining).

**server()**

Adds the server path, "/servers/{server}", to the request URI.

Arguments:

- `$server` - *string*: The name of the server to target.

Returns:

- `Request` - The request instance (allows chaining).

**route()**

Adds the route path, "/routes/{routeIndex}", to the request URI.

Arguments:

- `$routeIndex` - *int*: The route to target.

Returns:

- `Request` - The request instance (allows chaining).

**match()**

Adds the match path, "/match/{matchIndex}", to the request URI.

Arguments:

- `$matchIndex` - *int*: The match to target.

Returns:

- `Request` - The request instance (allows chaining).

**sendRequest()**

Sends the built request to the Caddy server.

Arguments:

- `$method` - *string*: The method for the request.
- `$body` - *array|nuullable*: The request body to send to Caddy.

Returns:

- `Response` - A new instance of a `Response` instance.

### Response

[](#response)

**\_\_constructor()**

Creates a new instance of the `Response` class.

Arguments:

- `$response` - *ResponseInterface*: Instance of a `ResponseInterface` (created by Guzzle).

**getBody()**

Returns the response body as a string.

No arguments.

**isSuccessful()**

Returns a boolean indicating if the request was successful. Status codes of 200 or 201 are considered successful, everything else is not.

No arguments.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/ohseesoftware/caddy-config-php/blob/master/LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~131 days

Recently: every ~197 days

Total

7

Last Release

1569d ago

Major Versions

v1.1.1 → v2.0.02019-12-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/0dafcec0352ac1a4de72f679bf2c72752d967bd388ec4e9c186142738993b945?d=identicon)[owenconti](/maintainers/owenconti)

---

Top Contributors

[![owenconti](https://avatars.githubusercontent.com/u/791222?v=4)](https://github.com/owenconti "owenconti (31 commits)")

---

Tags

apicaddyphpwrapper

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ohseesoftware-caddy-config-php/health.svg)

```
[![Health](https://phpackages.com/badges/ohseesoftware-caddy-config-php/health.svg)](https://phpackages.com/packages/ohseesoftware-caddy-config-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
