Page 1 of 1

How's my Specification?

Posted: Tue Jan 24, 2006 8:24 pm
by Ambush Commander
Before I sit down to hack out a ini file generation utility to aid my PHP switching, I decided that a new syntax for the configuration file would make things a lot easier for my purposes. So I drew out a specification. Do you think it's detailed enough?

Code: Select all

==Scratchpad==

===Global ini setup===

Because of the way PHP is set up, the ini file has to be called php.ini, so
we need seperate folders for each of the files. There are three files to be
called: the webserver file, the cli file, and the stable cli file.

ini_dir/
    generated/
        webserver/php.ini
        cli/php.ini
    custom/
        stable_cli/php.ini # for the php-switch itself

===Ini setup one===

Version by version basis. Inanely easy.

ini_dir/
    global/
        global.ini # all versions
        webserver.ini # further mask for webserver
        cli.ini # further mask for command line
      | 4.ini
      | 4.*.ini
      | 4.*.*.ini
      | 5.ini
      | 5.*.ini
      | 5.*.*.ini
      | 6.ini

===Ini setup two===

I think that the previous ini setup is way overkill. Remember, currently the
only customization we are doing is extension loading. If that is the case,
that we will always only be worried about extension loading in respect to
version, then it would be smarter to optimize the files for extensions.

We still need the global.ini, webserver.ini and cli.ini files to build
extensions off of. Also, we need some macros defined, such as PHP_DIRECTORY
which get substituted when the ini file is generated (especially for
extension_dir).

php_tidy.dll   / 4.3.11 4.4.1 5.0.5 5.1+
php_xdebug.dll / 4.3.11 4.4.0 4.4.1 5.0.5 5.1+
php_apd.dll    / 5.0.5 5.1+
php_apc.dll    / 4.3.11 4.4.0 5.1+
php_iconv.dll  / 4
php_w32api.dll / 4

php_zip.dll    / 4+
php_dbx.dll    / 4+
php_cpdf.dll   / 4+
... (and all other current extensions in the ini file)

Say, we can't get php_zip for 6.0.0-dev, then it becomes:

php_zip.dll    / 4+ !6.0.0-dev

The system does not seem to be configured for PHP 3 or less, and that's fine.
Four becomes a magic number, and 4+ means all versions. More formal syntax:

A valid line is:

/\${$dll_name}\s+\/\s+{$version_descriptions}{$comment}^/
  or
/\$\s+{$comment}^/

{$dll_name} is a valid filename with no spaces in it.

{$version_descriptions} is:

/((!)?[0-9]+(\.[0-9]+)*(-[A-Za-z]+)?(\+)?(\s)+)+/
  1   \-2------------/ \-3--------/  4

1 - NOT, which excludes the extension the optional blanket + operator
2 - Version number that can have 2 or 1 digits (then it matches all descendants)
3 - Special prefix, like "alpha" or "dev." Use sparingly!
4 - AND EVERYTHING LATER, which indicates extension is available for all later
    versions and that one. Since we don't support PHP 3, 4+ means all versions

{$comment} is: /\$;.+^/

Implementation details and test-cases needed. I don't think version ranges will
be implemented.

API would be like:

class Extension {
    var $filename;
    var $rules;
    function newFromFile($file) {return Extensions;}
    function newFromString($string) {return Extensions;}
    function isValid($version) {return bool;}
    function toIniLine() {return string;}
}

You grab a whole bunch of Extension objects from Extension::newFromFile(), then
loop through them all calling isValid, if it is valid, call toIniLine and append
to the configuration file. isValid would have all the version parsing black
magic, and new would be the "private" function that does the config file
parsing.

Posted: Tue Jan 24, 2006 9:55 pm
by Christopher
It's either brilliant or insane, I can't tell. :D

Seriously, by "aid my PHP switching" I assume that this helps in upgrading PHP to a new version by moving settings to the new php.ini file?

Posted: Tue Jan 24, 2006 10:08 pm
by Ambush Commander
No. You have multiple, concurrent installations of PHP in many different versions. Normal development switches between latest branches, and then backwards compatibility is checked by switching installation to more ancient releases for testing. Forwards compatibility can also be checked by switching to PHP5.