PHPackages                             kubotak-is/php-del - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kubotak-is/php-del

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kubotak-is/php-del
==================

Tool to remove code based on specific comments.

2.2.2(2w ago)1649.1k↓51.4%MITPHPPHP &gt;=8.2CI passing

Since Dec 2Pushed 2w ago2 watchersCompare

[ Source](https://github.com/kubotak-is/php-del)[ Packagist](https://packagist.org/packages/kubotak-is/php-del)[ RSS](/packages/kubotak-is-php-del/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (21)Used By (0)

PHP-DEL
=======

[](#php-del)

[![Unit Test](https://github.com/kubotak-is/php-del/actions/workflows/phpunit.yml/badge.svg?branch=main)](https://github.com/kubotak-is/php-del/actions/workflows/phpunit.yml)[![Latest Stable Version](https://camo.githubusercontent.com/b847d8fad4f0f44e5416b5fe89cbc424a5bb2bfde1cd86e76ca214014774245a/68747470733a2f2f706f7365722e707567782e6f72672f6b75626f74616b2d69732f7068702d64656c2f76)](https://packagist.org/packages/kubotak-is/php-del)[![PHP Version Require](https://camo.githubusercontent.com/a83c8fb8637b12a73f793ff3f87481f66e1b82892888826819db66054233cf8b/68747470733a2f2f706f7365722e707567782e6f72672f6b75626f74616b2d69732f7068702d64656c2f726571756972652f706870)](https://packagist.org/packages/kubotak-is/php-del)[![License](https://camo.githubusercontent.com/55b742f4e5acec6f512136d189e167feb3798e3ed58ba75409ca622f7c6ad8c4/68747470733a2f2f706f7365722e707567782e6f72672f6b75626f74616b2d69732f7068702d64656c2f6c6963656e7365)](https://packagist.org/packages/kubotak-is/php-del)

PHP-DEL is a CLI tool that permanently removes source code marked with `php-del` comments. It runs interactively by default and offers a non-interactive mode (`--flag`) for CI and AI-agent automation. It is useful for maintaining optional, environment-specific, or temporary code paths and removing one selected feature before a release or deployment.

```
public function example(): void
{
    /** php-del start legacy-api */
    $this->callLegacyApi();
    /** php-del end legacy-api */
}
```

After selecting `legacy-api`, the marked block and its marker comments are removed.

Requirements
------------

[](#requirements)

- PHP 8.2, 8.3, 8.4, or 8.5
- `ext-mbstring`
- Composer 2

PHP-DEL follows the PHP project's supported-version lifecycle.

Installation
------------

[](#installation)

Install PHP-DEL as a development dependency:

```
composer require --dev kubotak-is/php-del
```

Create `php-del.json` in the directory where the command will be run:

```
{
  "dirs": [
    "src",
    "resources/views"
  ],
  "extensions": [
    "php"
  ]
}
```

`dirs` paths are resolved from the current working directory. The `extensions` setting defaults to `["php"]` when omitted. Blade files are included by the `php` extension because their final extension is `.php`.

See [Configuration](docs/configuration.md) for all supported formats and examples.

Quick Start
-----------

[](#quick-start)

1. Add a flag to the code that should be removed:

    ```
    /** php-del start remove-me */
    $temporaryCode = true;
    /** php-del end remove-me */
    ```
2. Preview the operation:

    ```
    vendor/bin/php-del --dry-run
    ```
3. Select `remove-me` from the interactive list and inspect the reported files.
4. Run without `--dry-run` to apply the deletion:

    ```
    vendor/bin/php-del
    ```
5. Review the resulting diff:

    ```
    git diff
    ```

The command scans all configured files, counts each discovered flag, and prompts for one flag. It then processes every file containing that flag. To skip the prompt, pass `--flag=` (see [Non-interactive Mode](#non-interactive-mode)).

Marker Reference
----------------

[](#marker-reference)

### Delete a block

[](#delete-a-block)

```
/** php-del start feature-a */
$featureA = true;
/** php-del end feature-a */
```

### Delete one line

[](#delete-one-line)

Place a `line` marker on the line to remove:

```
use App\Legacy\Client; // php-del line feature-a
```

### Preserve part of a deleted block

[](#preserve-part-of-a-deleted-block)

`ignore` markers do not have a flag. Their contents survive when the surrounding flagged block is removed:

```
/** php-del start feature-a */
$removed = true;
/** php-del ignore start */
$preserved = true;
/** php-del ignore end */
/** php-del end feature-a */
```

Result:

```
$preserved = true;
```

### Delete an entire file

[](#delete-an-entire-file)

```
