Find all files (type f) that do not have a path containing "node_modules" and have a name ending with ".php" and execute the command "head -n 1" on each of them.
find . -type f ! -path */node_modules/* -name '*.php' -exec head -n 1 {} \;