PHPackages                             imanghafoori/php-search-replace - 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. imanghafoori/php-search-replace

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

imanghafoori/php-search-replace
===============================

Smart search replace functionality for php source code

v1.1.16(1y ago)32496.5k↓14.4%5[1 issues](https://github.com/imanghafoori1/php-smart-search-replace/issues)3MITPHPPHP ^7.1.3|8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*CI passing

Since Jul 31Pushed 1y ago1 watchersCompare

[ Source](https://github.com/imanghafoori1/php-smart-search-replace)[ Packagist](https://packagist.org/packages/imanghafoori/php-search-replace)[ Docs](https://github.com/imanghafoori1/php-smart-search-replace)[ RSS](/packages/imanghafoori-php-search-replace/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (29)Used By (3)

Php Smart Search/replace Functionality
======================================

[](#php-smart-searchreplace-functionality)

[![tests](https://github.com/imanghafoori1/php-smart-search-replace/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/imanghafoori1/php-smart-search-replace/actions/workflows/tests.yml)[![Coverage Status](https://camo.githubusercontent.com/aeb80ef2de66ad83ad8c93b78a5d892f1a9acd8774d8f91ca21bd0992a7ee9ca/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f696d616e676861666f6f7269312f7068702d736d6172742d7365617263682d7265706c6163652f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/imanghafoori1/php-smart-search-replace?branch=main)[![Total Downloads](https://camo.githubusercontent.com/c5ea430ba2cd17e7eb7b51247a23690a32ec57b4133962dc4e8a6e3b1ddbd027/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d616e676861666f6f72692f7068702d7365617263682d7265706c6163652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imanghafoori/php-search-replace)[![Latest Stable Version](https://camo.githubusercontent.com/d0b17f2a2be9814de31939a3582d008ed8c97b0b9a114fb5fbc821bdef448d91/68747470733a2f2f706f7365722e707567782e6f72672f696d616e676861666f6f72692f7068702d7365617263682d7265706c6163652f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/imanghafoori/php-search-replace)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Check Imports](https://github.com/imanghafoori1/php-smart-search-replace/actions/workflows/imports.yml/badge.svg?branch=main)](https://github.com/imanghafoori1/php-smart-search-replace/actions/workflows/imports.yml)

It is much easier than using regex.
-----------------------------------

[](#it-is-much-easier-than-using-regex)

### Installation:

[](#installation)

```
composer require imanghafoori/php-search-replace

```

### Usage:

[](#usage)

1- Lets say you want to remove double semi-colon occurances like these:

```
$user = 1;;
$user = 2; ;
$user = 3;
;
```

Then you can define a pattern like this:

```
$pattern = [';;' => ['replace' => ';']];
```

This will catch all the 3 cases above since the neutral php whitespaces are ignored while searching.

---

#### Placeholders:

[](#placeholders)

Here is a copmerehensive list of placeholders you can use:

- `` or ``: for variables like: `$user`
- `` or ``: for hard coded strings: `'hello'` or "hello"
- ``: for class references: `\App\User::where(...` , `User::where`
- ``: only for full references: `\App\User::`
- ``: to capture all the code until you reach a certain character.
- ``: for commands (does not capture doc-blocks)
- ``: for doc-blocks
- ``: to capture a whole php statement.
- `""` or ``: for method or function names. `->where` or `::where`
- ``: for whitespace blocks
- ``: for non-whitespace
- `` or `''`: for true or false (acts case-insensetive)
- ``: for numeric values
- ``: for type-casts like: `(array) $a;`
- `` or ``: for integer values
- ``: for public, protected, private
- ``: for floating point number
- `""`: to detect global function calls.
- ``: to capture code within a pair of `{...}` or `(...)` or `[...]`
- ``: captures any token.
- **You can also define your own keywords if needed!**

You just define a class for your new keyword and append the class path to the end of `Finder::$keywords[] = MyKeyword::class` property. Just like the default keywords.

### Example:

[](#example)

lets say you want to remove the optional comma from arrays:

```
$a = [
   '1',
   '2',
];
$b = ['1','2',];
```

Then you can define a pattern like this:

```
$pattern = [',?]' => ['replace' => '""]']];
```

Here the `?` mean an optional whitespace may reside there, and the `""` means the value that matches the first placeholder should be put there.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance43

Moderate activity, may be stable

Popularity47

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 89.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~116 days

Total

28

Last Release

440d ago

PHP version history (5 changes)v1.0.0PHP ^7.1.3|8.0.\*

v1.1.6PHP ^7.1.3|8.0.\*|8.1.\*

v1.1.10PHP ^7.1.3|8.0.\*|8.1.\*|8.2.\*

v1.1.12PHP ^7.1.3|8.0.\*|8.1.\*|8.2.\*|8.3.\*

v1.1.15PHP ^7.1.3|8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6961695?v=4)[Iman](/maintainers/imanghafoori1)[@imanghafoori1](https://github.com/imanghafoori1)

---

Top Contributors

[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (149 commits)")[![erfantkerfan](https://avatars.githubusercontent.com/u/37825504?v=4)](https://github.com/erfantkerfan "erfantkerfan (10 commits)")[![Danger-Mkh](https://avatars.githubusercontent.com/u/54482480?v=4)](https://github.com/Danger-Mkh "Danger-Mkh (6 commits)")[![thyseus](https://avatars.githubusercontent.com/u/654271?v=4)](https://github.com/thyseus "thyseus (1 commits)")

---

Tags

php-search-replace

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imanghafoori-php-search-replace/health.svg)

```
[![Health](https://phpackages.com/badges/imanghafoori-php-search-replace/health.svg)](https://phpackages.com/packages/imanghafoori-php-search-replace)
```

###  Alternatives

[marquine/php-etl

Extract, Transform and Load data using PHP.

182137.5k](/packages/marquine-php-etl)[hi-folks/data-block

Data class for managing nested arrays and JSON data.

1472.2k](/packages/hi-folks-data-block)[supermundano/sage-the-events-calendar

1724.5k](/packages/supermundano-sage-the-events-calendar)[practically/preloader

PHP preloading for PHP &gt;=7.4

1034.7k](/packages/practically-preloader)[jiten14/jitone-ai

jitone-ai is a powerful FilamentPHP plugin that integrates AI-powered features directly into your Filament forms.

213.1k](/packages/jiten14-jitone-ai)[defstudio/enum-features

A simple trait to enable a feature system using Enums and Laravel Pennant

162.1k](/packages/defstudio-enum-features)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
