PHPackages                             ali-eltaweel/expandr - 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. ali-eltaweel/expandr

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

ali-eltaweel/expandr
====================

Shell-style Parameters Expansion

1.0.1(2mo ago)05PHPPHP ^8.2

Since Feb 28Pushed 2mo agoCompare

[ Source](https://github.com/ali-eltaweel/expandr)[ Packagist](https://packagist.org/packages/ali-eltaweel/expandr)[ RSS](/packages/ali-eltaweel-expandr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Expandr
=======

[](#expandr)

**Shell-style Parameters Expansion**

- [Expandr](#expandr)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Substitution](#substitution)
        - [Slicing](#slicing)
        - [Right Trim](#right-trim)
        - [Left Trim](#left-trim)
        - [Case Transformation](#case-transformation)
        - [Indirection](#indirection)
        - [Default](#default)

---

---

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

[](#installation)

```
composer require ali-eltaweel/expandr
```

---

---

Usage
-----

[](#usage)

```
$expandr = new Expandr\Expandr([
  'name' => 'User'
]);

echo $expandr->processLine('Hello ${name}'); // Hello User
```

### Substitution

[](#substitution)

```
$expandr = new Expandr\Expandr([
  'x' => 'x_x_x'
]);

echo $expandr->processLine('${x/x/|}'); // |_x_x    (replace first)
echo $expandr->processLine('${x//x/|}'); // |_|_|   (replace all)
```

### Slicing

[](#slicing)

```
$expandr = new Expandr\Expandr([
  'chars' => 'abcdefgh'
]);

echo $expandr->processLine('${chars:0:4}'); // abcd
echo $expandr->processLine('${chars:2}'); // cdefgh
echo $expandr->processLine('${chars:-2}'); // gh
```

### Right Trim

[](#right-trim)

```
$expandr = new Expandr\Expandr([
  'path' => 'path/to/file.php'
]);

echo $expandr->processLine('Filename: ${path%.php}'); // Filename: path/to/file
```

### Left Trim

[](#left-trim)

```
$expandr = new Expandr\Expandr([
  'path' => 'path/to/file.php'
]);

echo $expandr->processLine('Filename: ${path##path/to/}'); // Filename: file.php
```

### Case Transformation

[](#case-transformation)

```
$expandr = new Expandr\Expandr([
  'username' => 'user',
  'USERNAME' => 'USER',
]);

echo $expandr->processLine('Hello ${username^}'); // Hello User
echo $expandr->processLine('Hello ${username^^}'); // Hello USER
echo $expandr->processLine('Hello ${USERNAME,}'); // Hello uSER
echo $expandr->processLine('Hello ${USERNAME,,}'); // Hello user
```

### Indirection

[](#indirection)

```
$expandr = new Expandr\Expandr([
  'a' => 'b',
  'b' => 'c',
  'c' => 'd'
]);

echo $expandr->processLine('${a}'); // b
echo $expandr->processLine('${!a}'); // c
echo $expandr->processLine('${!!a}'); // d
// and so on...
```

### Default

[](#default)

```
$expandr = new Expandr\Expandr([
  'a' => 'b'
]);

echo $expandr->processLine('${a:+a is set}'), // a is set
echo $expandr->processLine('${b:-b is not set}'), // b is not set
echo $expandr->processLine('${b:?b is not set}'), // throws an error with message "b is not set"
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance86

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Every ~0 days

Total

2

Last Release

71d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7564e10ba11b25d8700726a92f669e38be2ff9191e8f6ccdfafc36678ffab2b8?d=identicon)[ali-eltaweel](/maintainers/ali-eltaweel)

---

Top Contributors

[![ali-eltaweel](https://avatars.githubusercontent.com/u/45892756?v=4)](https://github.com/ali-eltaweel "ali-eltaweel (13 commits)")

### Embed Badge

![Health badge](/badges/ali-eltaweel-expandr/health.svg)

```
[![Health](https://phpackages.com/badges/ali-eltaweel-expandr/health.svg)](https://phpackages.com/packages/ali-eltaweel-expandr)
```

###  Alternatives

[webelightdev/laravel-slider

configer slider from UI

131.0k](/packages/webelightdev-laravel-slider)

PHPackages © 2026

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