Tim Jackson’s WebHostAPI for PHP

This is a simple PHP library which is able to parse metadata embedded in Apache HTTPD virtual hosts, and provide it back in the form of a PHP object.

This is useful when constructing a complex shared web hosting environment, to be able to write automated scripts to check the consistency of various things (for example to check which sites are owned by which clients and require which databases etc.)

WebHostAPI uses an “inline comments” methodology which tags virtual hosts with metadata looking like this:

<VirtualHost *>
  # owner: someclient
  # id: someclient-foo, somebardb
  # db: somedb
  # ssl:
  # stats: awstats

  ServerName host.example.com
  DocumentRoot /path/to/document_root

The basic format is obvious:

# key: value

Whitespace is not important, so the following are all equivalent:

# key: value
#key: value
# key    :   value

and so on. Tags are terminated by a newline and cannot span lines.

Multiple values are appropriate for certain tags, and these are handled like so:

# key: value1, value2

The tags are all optional. Currently supported tags are:

Tag Multiplicity Purpose/Description
owner single Textual identifier of the entity (e.g. client) who ‘owns’ the site.
id single Intended to be a unique ID to uniquely identify a particular deployed application.
db multiple List of named databases that the site uses.
ssl single For sites which use SSL, the service address (in either hostname or IPv4 format) to be used to listen on for incoming SSL connections.
stats multiple What web statistics to generate for the site, if any. Technically this can support multiple definitions, however ‘awstats’ is the only configuration currently supported. The value ‘none’ is supported to explicitly specify that no stats are required, although the absence of the tag has the same meaning.

Note that WebHostAPI does not actually do anything with these tags; it merely processes them and returns an object.


WebHostAPI v0.5.1