webhelper / parser
WebHelper Parser Interface
0.5.0
2016-09-18 10:59 UTC
Requires
- php: ^5.4 || ^7.0
- symfony/yaml: ^2.8 || ^3.1
- webmozart/glob: ^4.1
Requires (Dev)
- phpunit/phpunit: ^4.8 || ^5.5
README
Part of WebHelper, a Generic Httpd Configuration Helper.
Installation
composer require webhelper/parser
Basic Usage
Parse an Apache configuration file:
use WebHelper\Parser\Factory; use WebHelper\Parser\ParserException; use WebHelper\Parser\InvalidConfigException; $factory = new Factory() $parser = $factory->createParser('apache'); $parser->getServer()->setPrefix('/usr'); try { $activeConfig = $parser ->setConfigFile('/private/etc/apache2/httpd.conf') ->getActiveConfig(); echo $parser->getOriginalConfig(); echo var_export($activeConfig, true).PHP_EOL; } catch (ParserException $e) { //file not found var_dump($e->getMessage()); } catch (InvalidConfigException $e) { //empty config or syntax error var_dump($e->getMessage()); }
Or the same with Nginx
use WebHelper\Parser\Factory; $factory = new Factory() $parser = $factory->createParser('nginx'); $parser->getServer()->setPrefix('/usr/sbin/'); $activeConfig = $parser ->setConfigFile('/etc/nginx/nginx.conf') ->getActiveConfig(); // etc...
Known issues
- Does not support old macos9 file format.