Proposes for the PEARInstaller classes

From: Date: Wed, 11 Jun 2003 13:39:17 +0000
Subject: Proposes for the PEARInstaller classes
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17304@lists.php.net to get a copy of this message
While working on the installer classes to install whole applications, i've found two problems - and the solution for them: 1. The PEAR Installer classes uses the php_dir for storing the configuration data (registry etc.), which forces you to do some uncomfortable work, if you want to work with more then one installation on the computer. Propose: Add an "config_dir" entry to handle more then one registry on the system - the config data could be stored in ie: <config_dir>/PEAR for PEAR itself and <config_dir>/<App_Name> for Application distributed using the PEAR tools To keep BC, a method returning the config dir could be created like PEAR_Config::getConfigDir() - it should replace all calls of $config['php_dir'], where it is taken as configuration directory. This function would return the value of $config['config_dir'] if exists/not empty, else the php_dir. 2. The fileroles are hardcoded currently, which means you are running into trouble if you want to copy a file into an ie web-accessibly directory, because a filerole for this isn't defined. Propose: Move the current filerole detecting code to a class (ie PEAR_FileRole_Handler), this class has an method like getFileRoleDestination(). Under normal circumstances the install class behaves like the current version. But if you have an install script using the install class it could call a method like PEAR_Installer::registerFileRoleHandler($myFRHandler), where $myFRHandler is an reference to an own class instance to handle the fileroles. Ie. if you want support an additional filerole "htdoc" for a web directory you wold write something like this: class myFRHandler extends PEAR_FileRole_Handler { function getFileRoleDestination($fr, ...) { select($fr) { case "htdoc": return "/users/alex/htdocs/mydir"; default: return PEAR_FileRole_Handler::getFileRoleDestination($fr, ...); } } } ... $frh=new myFRHandler(); PEAR_Config::registerFileRoleHandler($frh); ... In the installer classe we just have to made a simple change to ie: $frh=$config->getFileRoleHandler(); Where $frh contains a custom filehandler if one is registered or an instance of PEAR_FileRole_Handler, if no one is registered. Both changes doesn't cause any BC breaks, but makes customizable install scripts easier.

« previous php.pear.dev (#17304) next »