Skip to content

Instantly share code, notes, and snippets.

@phoshp
Last active November 27, 2020 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phoshp/b13fec79481e746225179f45e31d4b5a to your computer and use it in GitHub Desktop.
Save phoshp/b13fec79481e746225179f45e31d4b5a to your computer and use it in GitHub Desktop.
A basic php script for lazy devs to know how much line they have coded
<?php
$dirs = [
// ADD YOUR DIRS
];
$targetExtensions = [
// EXAMPLE
"php" => true,
"css" => true
];
$codeline = 0;
foreach($dirs as $dir){
$dir = str_replace("\\", "/", $dir);
if(!is_dir($dir)){
print_r("There is not a directory with path name: " . $dir . "\n");
continue;
}
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $file){
$path = $file->getPathname();
if(isset($targetExtensions[$file->getExtension()])){
$content = file_get_contents($path);
$codeline += substr_count($content, "\n") + 1;
}
}
}
print_r("Total Code Line: " . $codeline);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment