PHPackages                             phine/phar-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. phine/phar-replace

AbandonedArchivedLibrary

phine/phar-replace
==================

Adds search and replace support for the phar library.

1.0.0(12y ago)0527MITPHPPHP &gt;=5.3.3

Since Jan 14Pushed 12y agoCompare

[ Source](https://github.com/kherge-archive/lib-phar-replace)[ Packagist](https://packagist.org/packages/phine/phar-replace)[ Docs](https://github.com/phine/lib-phar-replace)[ RSS](/packages/phine-phar-replace/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Phar Replace
============

[](#phar-replace)

[![Build Status](https://camo.githubusercontent.com/274fa6075a0f72f1e29ea1c4407d2ac72acdca69e41bd680bace856f082a8c79/68747470733a2f2f7472617669732d63692e6f72672f7068696e652f6c69622d706861722d7265706c6163652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/phine/lib-phar-replace)[![Coverage Status](https://camo.githubusercontent.com/77546c515b6a22507ee19fa58288b93976a5f314ac27e82f21532df51476a69a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7068696e652f6c69622d706861722d7265706c6163652f62616467652e706e67)](https://coveralls.io/r/phine/lib-phar-replace)[![Latest Stable Version](https://camo.githubusercontent.com/fe4f9ee646f8ca9ee5c77e75b10fda97f0168695b9025c643ee9c7a840bf11eb/68747470733a2f2f706f7365722e707567782e6f72672f7068696e652f706861722d7265706c6163652f762f737461626c652e706e67)](https://packagist.org/packages/phine/phar-replace)[![Total Downloads](https://camo.githubusercontent.com/2d4ca61b2c7d2c11dc62a6f57e03d9cc065ac05d9874a0dc55e61aab3937f142/68747470733a2f2f706f7365722e707567782e6f72672f7068696e652f706861722d7265706c6163652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/phine/phar-replace)

Adds search and replace support for the phar library.

Requirement
-----------

[](#requirement)

- PHP &gt;= 5.3.3
- [Phine Exception](https://github.com/phine/lib-exception) &gt;= 1.0.0
- [Phine Observer](https://github.com/phine/lib-observer) &gt;= 2.0
- [Phine Phar](https://github.com/phine/lib-phar) &gt;= 1.0.0

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

[](#installation)

Via [Composer](http://getcomposer.org/):

```
$ composer require "phine/phar-replace=~1.0"

```

Usage
-----

[](#usage)

The library provides a single subject observer for lib-phar. This observer can be registered to the following subjects in order to perform a global search and replace of one or more search strings:

- `Builder::ADD_FILE`
- `Builder::ADD_STRING`

To create an observer, you will need a new instance of `ReplaceObserver`.

```
use Phine\Phar\Builder;
use Phine\Phar\Replace\ReplaceObserver;

// create the archive builder
$builder = Builder::create('example.phar');

// create the replace observer
$observer = new ReplaceObserver(
    array(
        'search' => 'replace',
        '@search@' => 'replace',
        '{{ search }}' => 'replace',
        // ...etc...
    )
);

// register it with the builder subjects
$builder->observe(Builder::ADD_FILE, $observer);
$builder->observe(Builder::ADD_STRING, $observer);
```

With the observer registered, any file or string added will all of its `search`, `@search@`, `{{ search }}` string occurrences replaced with the value `replace`.

> It may be important to note that only scalar values are supported.

You may also set search strings and replacement values after the observer has been created by calling either `setSearchValue()` or `setSearchValues()`:

```
// add a value
$observer->setSearchValue('search string', 'replacement value');

// replace a value
$observer->setSearchValue('search string', 'a different value');

// replace all search strings and their values
$observer->setSearchValues(
    array(
        'search' => 'replace',
        '@search@' => 'replace',
        '{{ search }}' => 'replace',
        // ...etc...
    )
);
```

By using `setSearchValues()`, you will be removing all previous search strings and their replacement values. Only the new search strings and replacement values provided will be used.

Documentation
-------------

[](#documentation)

You can find the API [documentation here](http://phine.github.io/lib-phar-replace).

License
-------

[](#license)

This library is available under the [MIT license](LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

4505d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9122157?v=4)[Kevin Herrera](/maintainers/kherge)[@kherge](https://github.com/kherge)

---

Top Contributors

[![kherge](https://avatars.githubusercontent.com/u/9122157?v=4)](https://github.com/kherge "kherge (5 commits)")

---

Tags

pharreplace

### Embed Badge

![Health badge](/badges/phine-phar-replace/health.svg)

```
[![Health](https://phpackages.com/badges/phine-phar-replace/health.svg)](https://phpackages.com/packages/phine-phar-replace)
```

###  Alternatives

[seld/phar-utils

PHAR file format utilities, for when PHP phars you up

875180.0M32](/packages/seld-phar-utils)[phalcon/devtools

This tools provide you useful scripts to generate code helping to develop faster and easy applications that use with Phalcon framework.

1.3k2.0M54](/packages/phalcon-devtools)[humbug/box

Fast, zero config application bundler with PHARs.

1.3k801.5k69](/packages/humbug-box)[clue/phar-composer

Simple phar creation for any project managed via Composer

862881.6k29](/packages/clue-phar-composer)[typo3/phar-stream-wrapper

Interceptors for PHP's native phar:// stream handling

5938.0M8](/packages/typo3-phar-stream-wrapper)[raulfraile/distill

Smart compressed files extractor

228190.4k9](/packages/raulfraile-distill)

PHPackages © 2026

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