nicolus/apache-config-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nicolus/apache-config-parser

最新稳定版本:v1.0.0

Composer 安装命令:

composer require nicolus/apache-config-parser

包简介

Easily get configured domains from an Apache2 config file

README 文档

README

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 :

composer require nicolus/apache-config-parser

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 :

  • "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.

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2022-07-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固