In my Beyond Frameworks talk, I explained how a component-based architecture can help answer some of the important (i.e. expensive!) questions you might face when creating long-lived apps that rely on a PHP framework. In this series of blog posts, I'm going to look at how to go about creating and working with components.
phix is a small command-line tool for PHP applications. I created it to fix (pun intended) the problem of how to easily automate the tasks involved in creating and (especially) maintaining components. These tasks aren't built into phix; they are commands that ship with the phix distribution. You can create your own commands to run inside phix too, and it's easy to do so.
You can install phix via the PEAR installer:pear channel-discover pear.gradwell.com pear install --alldeps Gradwell/phix
This will install the phix command-line tool (normally as /usr/bin/phix on Linux systems), and its associated libraries into your PHP search path (normally /usr/share/php on Linux systems).
What Can phix Do?
Running phix without any command-line parameters gives us a basic overview of what it can do:phix 0.10.4 http://gradwell.github.com Copyright (c) 2010 Gradwell dot com Ltd. Released under the BSD license SYNOPSIS /usr/bin/phix [ -?dhv ] [ --? --debug --help --version ] [ -I ] [ --include= ] [ command ] [ command-options ] OPTIONS Use the following switches in front of any to have the following effects. -? | -h display a summary of the command-line structure -I | --include= add a folder to load commands from phix finds all of its commands by searching PHP's include_path for PHP files in folders called 'PhixCommands'. If you want to phix to look in other folders without having to add them to PHP's include_path, use --include to tell phix to look in these folders. phix expects '' to point to a folder that conforms to the PSR0 standard for autoloaders. For example, if your command is the class '\Me\Tools\PhixCommands \ScheduledTask', phix would expect to autoload this class from the 'Me /Tools/PhixCommands/ScheduledTask.php' file. If your class lives in the './myApp/lib/Me/Tools/PhixCommands' folder, you would call phix with 'phix --include=./myApp/lib' -d | --debug enable debugging output -v | --version display phix version number --? | --help display a full list of supported commands COMMANDS help # get detailed help about a specific phix command pear:expand-package-xml # expand the tokens and contents of the PEAR-compatible package.xml file pear:register-channels # register the channels for the dependencies listed in the PEAR-compatible package.xml file php-docbook:init # initialise the directory structure of a php-docbook component php-library:init # initialise the directory structure of a php-library component php-library:status # check the status of a php-library component php-library:upgrade # upgrade the structure of a php-library component to the latest version php-webapp:init # initialise the directory structure of a php-webapp component php-webapp:status # check the status of a php-webapp componentSee /usr/bin/phix help for detailed help on
Right now, phix ships with a bunch of commands for creating and working with components. The php-library: commands have had the most attention to date, and the php-docbook: command has just been added this weekend. (The pear: commands are used to assist in building PEAR-compatible packages from a component, something I'll look at in a later blog post).
You can add your own commands to this list with minimal effort, something we'll look at in a later blog post. By default, phix searches your PHP include_path for new PhixCommands namespaces to load; you can also use the
Truncated by Planet PHP, read more at the original (another 1981 bytes)