Last active
October 4, 2024 19:19
-
-
Save jakebathman/15010bcaa72d6d5232dd1c9c19c0a837 to your computer and use it in GitHub Desktop.
Remove comments from fresh Laravel files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Remove Laravel Comments | |
|-------------------------------------------------------------------------- | |
| | |
| Just made a new Laravel project, but don't want all those big | |
| comment blocks? Put this in the root of your project and run | |
| "php remove_laravel_comments.php" | |
| | |
*/ | |
$directories = [ | |
'app', | |
'bootstrap', | |
'config', | |
'database', | |
'public', | |
'resources', | |
'routes', | |
]; | |
$base = './'; | |
foreach ($directories as $dir) { | |
$it = new RecursiveDirectoryIterator($base . $dir); | |
foreach (new RecursiveIteratorIterator($it) as $file) { | |
if ($file->getExtension() == 'php') { | |
echo "Removing comments from: " . $file->getRealPath() . "\n"; | |
$contents = file_get_contents($file->getRealPath()); | |
$new = preg_replace('/^(\{?)\s*?\/\*(.|[\r\n])*?\*\/([\r\n]+$|$)/im', '$1', $contents); | |
file_put_contents($file->getRealPath(), $new); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're a superstar, thanks a bunch! Starred.