I have a large php project and different developers work on the same project. Changes in php file e.g syntax error can lead to 500 internal server error if another developer tries to run the same project - leaving the other developer clueless as to where the error is from. I need to download some batch file that checks the whole project and displays the line numbers and errors that occured for each file in the project and not just in one file e.g. when using php -l filename - instead I want it to be php -l project
3 Answers
If you are using linux, this command will check your current folder recursively for all php files, syntax check them and filter out the ones that are OK:
find . -name \*.php -exec php -l {} \; | grep -v "No syntax errors"
You'll get a nice list of files and errors.
1 Comment
Edit: Turns out the OP is looking for a way to activate error reporting. I'll leave this in place anyway because I'm sure it's good universal advice for many in similar situations.
I don't know your situation, but to me, it sounds like what you might really need is a proper deployment process using at least a version control system. Multiple developers working on the same files simultaneously without any version control is a recipe for disaster, that much I can guarantee you.
Some starting points:
An introduction into VCS mercurial that is very nicely done and helps understand how version control works
Here is a programmers.SE question that might suit your situation: https://softwareengineering.stackexchange.com/questions/74708/source-control-on-a-live-shared-hosting-site
3 Comments
error_reporting and display_errors PHP.ini options, activating both should give you the errors directly.$it = new RecursiveIteratorIterator( new RecursiveDirectoryIterator('.'));
$regx = new RegexIterator($it, '/^.*\.php$/i', // only matched text will be returned
RecursiveRegexIterator::GET_MATCH);
foreach ($regx as $file) {
$file = $file[0];
exec('php -l ' . $file); //check the syntax here
}
php -l projectwill never catch any errors that are caused by runtime conditions, so it will probably not be very useful.