Re: Howto develop PEAR package using data_dir

From: Date: Fri, 12 Sep 2008 05:44:28 +0000
Subject: Re: Howto develop PEAR package using data_dir
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-50746@lists.php.net to get a copy of this message
Hello invalid user, First, using an invalid email address is really bad behavior. > During development these datafiles are in the same directory as my > php files, but after installing the package with the pear command the > files are in a different directory. I'm using > PEAR_Config::singleton()->get('data_dir') to get the directory. > Obviously testing the code fails because the files aren't in the > data_dir, or maybe there are just old files there. > > But how do I easily run my code without installing the package over > and over again? There are two ways to accomplish this: 1) Use package replacement tasks. This means that during package installation, pear replaces certain strings in your .php files with config options, e.g. "@data_dir@" with /path/to/pear/data/dir. You can check if this happened in your code, e.g. if ('@data_dir@' == '@' . 'data_dir@') { //not replaced, use development path } 2) Do a file_exists in your script to check if your relative data directory exists and use it then. 3) Installing a development package is done via "pear upgrade -f package.xml" really easily. -- Regards/Mit freundlichen Grüßen Christian Weiske -= Geeking around in the name of science since 1982 =-

Attachment: [application/pgp-signature] signature.asc
« previous php.pear.dev (#50746) next »