To count lines of code in file:
wc -l filename
To count lines in all php files in a directory
wc -l *.php
This command counts lines in all php files in a directory but ignore its subdirectories. To include subdirectories, use the following command
find . -name '*.php' | xargs wc -l