Click to See Complete Forum and Search --> : PHP feature request ...
dalecosp
03-18-2006, 11:10 AM
This morning I found that I wanted to do this ...
$ cd foobar
$php -l *Apparently, the wildcard defaults to only one file (no big discovery, as RTFM seems to suggest).
But, wouldn't it be *nice* to be able to do that?
Would it be nice enough to have to justify the PITA that it'd be to add the feature?
Well, shoot. Shooting off my mouth pretty quickly --- this would probably be better asked on a mail list ... nonetheless, if you've an opinion, it'd be nice to hear....
bubblenut
03-18-2006, 09:10 PM
How about?
#!/bin/bash
# PHP Syntax Check
# Usage:
# phps [file(s)]
for file in "$@"
do
if $(echo $file | grep -q "\.php$")
then
php -l $file
fi
done
Incidentally I wrote a little script (attached) which we use at work for uploading files to the live site. It determines which site you're uploading to from your current working directory, syntax checks, commits to CVS and then uploads the files. It gets a little angry with parameter expansion sometimes, but on the whole it works really well.
I was reading Pragmatic Version Control with CVS and it mentioned something really interesting I've yet to try. Attaching scripts to cvs actions so, for example, we could require that a particular check script exits cleanly for a commit to go through. If you couple this with a slick CVS architecture , say, for example, a two branch aproach. One branch for the live site and then a development branch. When you want anything to go live you simply merge the changes from the dev branch to the live branch and run an update on the live site. This way you can attach a whole bunch of tests to the merge. PHP syntax checks, Unit tests, Output well-formedness tests, whatever you like. OK, it would be a mamoth task to set up but you'd be able to sleep like a baby ;)
dalecosp
03-18-2006, 10:29 PM
Not a bad bash script. I don't do bash, but enough sh to see it would work.
About the time I wrote this post I found this in another working dir:[512] Sat 18.Mar.2006 20:24:28
[kadmin@archangel][/www/data/biz/functions-dir]
cat lint.php
<?php
$dir=`ls -1`;
$newls=explode("\n",$dir);
foreach ($newls as $nn) {
system("php -l ./$nn");
}
?>So, there's my "dirty hack" to contribute (and in PHP, no less ... heh, like that's a big deal---now, modula3, that might ... nevermind.) ;) And, no reason I couldn't put it in my $PATH and make some adjustments...
Anyway, thanks for the reply. I was just wondering if anyone else ever thought, "why doesn't the PHP CLI do this" in the vein I was attempting to use it this morning...I imagine it's just that there's no time to code the small stuff...
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.