Download the PHP package nicolus/apache-config-parser without Composer
On this page you can find all versions of the php package nicolus/apache-config-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nicolus/apache-config-parser
More information about nicolus/apache-config-parser
Files in nicolus/apache-config-parser
Package apache-config-parser
Short Description Easily get configured domains from an Apache2 config file
License GPL-3.0-or-later
Informations about the package apache-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
Installation
Install it with composer :
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 :
would output something like :
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
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.