OK, so it's very, very quick and dirty - something like 10 minutes work here to write and test. But it's useful, I through it at the entire SVN repo and it checks the syntax of files. Very handy if I've made a big change and need to syntax check it.
I even found a bug with it just now.
Code: [Select]
You will likely need to change the paths to suit yourself though.
I even found a bug with it just now.
<?php
$base_path = 'C:/Dev/public_html/wedge/trunk';
$php = 'C:/wamp/bin/php/php5.3.10/php.exe';
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base_path), RecursiveIteratorIterator::SELF_FIRST);
foreach($objects as $name => $object){
if (is_file($name) && substr($name, -4) == '.php')
$filelist[] = $name;
}
$success = array();
$failure = array();
foreach ($filelist as $file)
{
$result = shell_exec($php . ' -l ' . $file);
$file = substr($file, 30);
if (trim($result) == '')
continue;
elseif (strpos($result, 'No syntax errors') === 0)
$success[] = $file;
else
echo $file, '<br>', $result, '<br><br>';
flush();
}
echo '<hr>The following files were all successful:<br>', implode('<br>', $success);You will likely need to change the paths to suit yourself though.




