-
-
Save alphaolomi/79ce8509076162caff9e69509481f9cb to your computer and use it in GitHub Desktop.
Remove comments from fresh Laravel files
This file contains hidden or 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