This project is a powerful and lightweight PHP utility created by Ashikur Rahman Provat. It is designed to clean your source code by automatically removing unnecessary comments from PHP, Blade, and JavaScript files.
The PHP Comment Remover handles single-line, multi-line, and framework-specific comments (like Laravel Blade) using optimized Regular Expressions. For more tools and web development services, visit arprovat.com.
- ✅ Multi-Language Support: Works with PHP, JS, JSX, TS, TSX, and Vue files.
- ✅ Blade Engine Support: Specifically removes Laravel's
{{-- --}}comments. - ✅ Recursive Scanning: Automatically processes all sub-folders within a directory.
- ✅ Single File Mode: Option to clean a specific file instead of an entire project.
- ✅ Regex Powered: Fast and accurate removal of
//and/* */patterns.
Server: PHP 8.x (Regex, RecursiveDirectoryIterator)
- You must have a PHP-supported environment (e.g., Laragon, XAMPP, or CLI).
- Clone the script or create a
tools.phpfile in your project root. - Set your target path (file or folder) at the bottom of the script:
// For a specific file:
$inputPath = './test.php';
// For an entire directory:
$inputPath = './src';
processPath($inputPath);Open your terminal or command prompt and run:
php tools.php- Language: PHP 8.x
- Core Engine: Regex (Regular Expressions)
- Iterator: RecursiveDirectoryIterator & RecursiveIteratorIterator
This tool directly overwrites your original files. It is highly recommended to perform a Git Commit or take a backup before running the script to avoid losing any critical documentation.
Contributions are welcome! If you'd like to improve the regex patterns or add more file support, feel free to fork the repository and submit a pull request.
If you encounter any issues or have suggestions for improvement, please open an issue on GitHub.