Re: Proposal: A need for simple development helping tools/scripts
| From: | Tomas V.V.Cox | Date: | Thu, 12 Jun 2003 01:25:04 +0000 |
| Subject: | Re: Proposal: A need for simple development helping tools/scripts | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17337@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Jesus M. Castagnetto" <jcastagnetto@yahoo.com>
>
> --- "Tomas V.V.Cox" <cox@idecnet.com> wrote:
> >
> > ----- Original Message -----
> > From: "Jesus M. Castagnetto" <jcastagnetto@yahoo.com>
> >
> >
> > > I remember that Greg mentioned that he built a script to generate a
> > package.xml
> > > file. That would be a boon for PEAR packages with a complex tree. I
saw
> > that
> > > script in the phpDocumentor's CVS tree (scripts/create_package.xml),
and
> > with
> > > some little tinkering it could be adapted to be general.
> > >
> > > Ideas/suggestions/pointers/recommendations?
> >
> > Some pointers:
> >
> > php4/pear/PEAR/Common.php methods:
> >
> > infoFromDescriptionFile(): reads a package.xml file and returns its
> > information as an array.
> > xmlFromInfo(): takes an array (with the format of the infoFrom*()
methods)
> > and builds the package.xml file.
>
> Nope not that type. Something along the lines of generating a package.xml
from
> the directory tree automagically. Not from a manually constructed array
;-)
>
> Check:
>
>
http://cvs.joshuaeichorn.com/co.php/phpdoc/scripts/create_package.xml.php?r=
1.22
>
> That can be modified to be used in newer programs to jump-start the
package
> writting.
My pointer was precisely to avoid the huge work of creating the xml by hand.
It's for far easier to map the filesystem to a simple array and then call
xmlFromInfo() to create the xml file, than doing like this script. Btw, if
the format of the xml changes, you'll need to change the script too, while
using the exact method that the pear cmd uses this won't be a problem.
See how easy could that tool look in few lines:
<?php
include 'PEAR/Common.php';
include 'System.php';
$common = new PEAR_Common;
$pkginfo = $common->infoFromFile('sample_skeleton_package.xml');
$find = System::_dirToStruct(getcwd()); // Sorry for this ;)
$filelist = array();
foreach($find['files'] as $file) {
$filelist[] = array($file, array('role' => guessRole($file)));
}
$pkginfo['filelist'] = $filelist;
$fp = fopen('package.xml', 'w');
fputs($fp, $common->xmlFromInfo($pkginfo));
fclose($fp);
?>
> As for putting all the devel tools in a package, I guess it would OK too.
I can
> contribute my ugly (but working) script to generate a skeleton for a unit
test
> class (just to save some typing ;-), it is in
Math_Stats/test/mkUnitTest.php.
Something for generating API Docs would be nice too.
Tomas V.V.Cox