PHPackages                             nicolus/apache-config-parser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nicolus/apache-config-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nicolus/apache-config-parser
============================

Easily get configured domains from an Apache2 config file

v1.0.0(3y ago)329GPL-3.0-or-laterPHP

Since Jul 31Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nicolus/apache-config-parser)[ Packagist](https://packagist.org/packages/nicolus/apache-config-parser)[ RSS](/packages/nicolus-apache-config-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Apache2 Config Parser
---------------------

[](#apache2-config-parser)

This is a small PHP library which allows you to parse an Apache2 config file and list every site configured site with its domain, port, document root and aliases. It is loosely based on this repo : [https://github.com/shabuninil/apache\_config\_parser](https://github.com/shabuninil/apache_config_parser)

### Installation

[](#installation)

Install it with [composer](https://getcomposer.org/) :

```
composer require nicolus/apache-config-parser
```

### Usage

[](#usage)

Create a new `Parser` by providing a starting point (either an Apache2 configuration file, or a directory that contains configuration files), and use the `->getHosts()` method to retrieve an array of `Hosts`.

For example :

```
use Nicolus\ApacheConfigParser\Parser;

require 'vendor/autoload.php';

$parser = new Parser('/etc/apache2/apache2.conf');
$hosts = $parser->getHosts();

print_r($hosts);
```

would output something like :

```
Array
(
    [0] => Nicolus\ApacheConfigParser\Host Object
        (
            [name] => example.com
            [port] => 80
            [root] => /var/www/example.com/
            [aliases] => Array
                (
                    [0] => www.example.com
                )
        )

    [1] => Nicolus\ApacheConfigParser\Host Object
        (
            [name] => example.com
            [port] => 443
            [root] => /var/www/example.com/
            [aliases] => Array
                (
                    [0] => www.example.com
                )
        )

    [2] => Nicolus\ApacheConfigParser\Host Object
        (
            [name] => mysite.com
            [port] => 443
            [root] => /var/www/mysite/public/
            [aliases] => Array
                (
                )
        )

```

### Notes :

[](#notes-)

- "Include" and "IncludeOptional" directives are respected and will load the included files.
- The '\*' wildcards in includes are respected.
- If you pass a directory path ending with a `/` (eg. `/etc/apache2/sites-enabled/`) it will load all files in this directory and its subdirectories recursively, and then handle includes.
- This is definitely not a full blown parser, it should cover most regular usecases, but expect it to break in some edge cases.

### Support and contributions

[](#support-and-contributions)

If you encounter a problem feel free to open an issue on github and describe what went wrong with an example config file.

Pull requests are welcome, especially if they don't break tests or add new tests.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1387d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25a8f14dbe1d52dc6f458f69988c4491a2f8cb9ba4c3d30eb963410d8b2ee9df?d=identicon)[nicolus](/maintainers/nicolus)

---

Top Contributors

[![nicolus](https://avatars.githubusercontent.com/u/3315078?v=4)](https://github.com/nicolus "nicolus (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nicolus-apache-config-parser/health.svg)

```
[![Health](https://phpackages.com/badges/nicolus-apache-config-parser/health.svg)](https://phpackages.com/packages/nicolus-apache-config-parser)
```

###  Alternatives

[bacon/bacon-qr-code

BaconQrCode is a QR code generator for PHP.

2.1k165.5M372](/packages/bacon-bacon-qr-code)[evenement/evenement

Événement is a very simple event dispatching library for PHP

1.3k147.0M319](/packages/evenement-evenement)[lcobucci/clock

Yet another clock abstraction

790190.9M114](/packages/lcobucci-clock)[ircmaxell/random-lib

A Library For Generating Secure Random Numbers

84130.2M119](/packages/ircmaxell-random-lib)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)

PHPackages © 2026

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