15
Cognifty 19: Phing is the module installer
A few weeks ago I posted about how I thought phing should be used as more of a run-time work-horse than a compile time only tool.
Release 19 of Cognifty uses Phing as the basis for its module installer. Module authors write a standard "install.xml", and the current versions determine which target gets called.
For new installations, target "install" is called.
<target name="install">
<phingcall target="Copyfiles"/>
<phingcall target="CopyIcons"/>
</target>
For upgrades, two types of targets are searched for. One is the specific version upgrade
<target name="upgrade_2_to_3">
<phingcall target="Copyfiles"/>
</target>
Or, for more generic upgrades, targets which upgrade any version to the latest can be specified like so:
<target name="upgrade_any_to_6">
<phingcall target="createtables"/>
</target>
The install.xml files can consist of any number of targets and phing calls, but only 1 target is run at a time. This allows the person performing the install to see step-by-step what the output is for each Phing target. Splitting your installation up into logical steps should also help the end-user recover from unexpected situations. If somethign goes wrong the end-user should only have to perform one step by hand.
There is also an option to skip steps which fail. Perhaps the site owner corrected a permission issue and wants to try a module installation again. If any step before the step which originally fails does not succeed, it can be skipped. This situation might arise when you are creating SQL tables, and creating them a second time throws an error. This type of situation is recoverable by the end-user and does not stop the entire installation from continuing.




