tetreum / apache-vhost-processor
Apache VirtualHost files processor in PHP
Installs: 1 353
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 0
Open Issues: 0
This package is auto-updated.
Last update: 2025-01-19 04:14:52 UTC
README
Apache VirtualHost files processor (in PHP)
Being used at https://github.com/tetreum/vhostmanager
Install
composer require tetreum/apache-vhost-processor "dev-master"
Example
require "vendor/autoload.php"; use Apache\Config\VirtualHost; use Apache\Config\Directive; use Apache\Config\Directory; $vhost = new VirtualHost("*", 80); $vhost->addDirective(new Directive("DocumentRoot", "/var/www/mongo/current/htdocs")); $vhost->addDirective(new Directive("ServerName", "mongo.dev")); $vhost->addDirective(new Directive("ServerAdmin", "bill@mongo.dev")); $directory = new Directory("/api"); $directory->addDirective(new Directive("DocumentRoot", "/var/www/mongo/current/api")); $vhost->addDirectory($directory); print_r($vhost->toString());
Output:
<VirtualHost *:80>
DocumentRoot /var/www/mongo/current/htdocs
ServerName mongo.dev
ServerAdmin bill@mongo.dev
<Directory /api>
DocumentRoot /var/www/mongo/current/api
</Directory>
</VirtualHost>