Skip to content

Instantly share code, notes, and snippets.

@codeitlikemiley
Last active June 8, 2019 04:39
Show Gist options
  • Select an option

  • Save codeitlikemiley/df3db9bc6588262735f4866089a92f93 to your computer and use it in GitHub Desktop.

Select an option

Save codeitlikemiley/df3db9bc6588262735f4866089a92f93 to your computer and use it in GitHub Desktop.
Remove Block of Line
diff --git a/composer.json b/composer.json
index 8e2b2d7..38f96b4 100644
--- a/composer.json
+++ b/composer.json
@@ -15,9 +15,6 @@
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
- "filp/whoops": "^2.0",
- "fzaninotto/faker": "^1.4",
- "mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
$path_to_file = base_path('composer.json');
// The Whole Content of composer.json
$block_of_lines = file_get_contents($path_to_file);
// List of composer packages
$unwanted_words = array("filp/whoops", "fzaninotto/faker", "mockery/mockery");
$unwanted_words_match = '(?:' . join('|', array_map(function($word) {
return preg_quote($word, '/');
}, $unwanted_words)) . ')';
$replace_match = '/^.*' . $unwanted_words_match . '.*$(?:\r\n|\n)?/m';
$result = preg_replace($replace_match, '', $block_of_lines);
file_put_contents($path_to_file,$result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment