PHPackages                             el-gitto-junior/string - 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. el-gitto-junior/string

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

el-gitto-junior/string
======================

A collection of basic string manipulation functions.

v1.1.1(9y ago)0201MITPHPPHP ^5.4 || ^7.0

Since Jul 19Pushed 7y agoCompare

[ Source](https://github.com/ElGittoJunior/string)[ Packagist](https://packagist.org/packages/el-gitto-junior/string)[ Docs](https://github.com/phpgearbox/string)[ RSS](/packages/el-gitto-junior-string/feed)WikiDiscussions v0.6.1 Synced 2mo ago

READMEChangelog (1)Dependencies (9)Versions (17)Used By (1)

The String Gear
===============

[](#the-string-gear)

[![Build Status](https://camo.githubusercontent.com/a190cc203039b64c10bd6ea8cc187b759d720e3b4855b0546dfb23a620ba627e/68747470733a2f2f7472617669732d63692e6f72672f70687067656172626f782f737472696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpgearbox/string)[![Latest Stable Version](https://camo.githubusercontent.com/d2800822527a6decf0a8ab4506574de0a4a73cb24eac2d6df5e90686f26fd43b/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f762f737461626c652e737667)](https://packagist.org/packages/gears/string)[![Total Downloads](https://camo.githubusercontent.com/4337a01661dd96e5580b2431bde50b7e08ae422e6e89a9acab29642bc5fc8b63/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f646f776e6c6f6164732e737667)](https://packagist.org/packages/gears/string)[![License](https://camo.githubusercontent.com/b72a3b19e6ed88dd727b61722375219d8d04e4c653fcf3e46d241e6ea184f710/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f6c6963656e73652e737667)](https://packagist.org/packages/gears/string)

A collection of basic string manipulation functions. There are 2 APIs:

- One procedural based using name spaced functions / static method calls.
- And a more fluent object based API.

I am not going to bother documenting every single last function here but please see below for some general usage examples. The rest you can work out for yourself by reading the source, it's fairly straight forward and well commented.

How to Install
--------------

[](#how-to-install)

Installation via composer is easy:

```
composer require gears/string:*

```

How to Use
----------

[](#how-to-use)

Here are a few procedural examples:

```
// returns true
Gears\String\contains('this is a test', 'test');

// returns 'this is a test'
Gears\String\between('this is a test', '', '');

// returns 'cde'
Gears\String\subString('abcdeg', 2, 5);
```

In PHP 5.6 you can import functions so you could change the above to:

```
// Import the functions
use function Gears\String\contains;
use function Gears\String\between;
use function Gears\String\subString;

// returns true
contains('this is a test', 'test');

// returns 'this is a test'
between('this is a test', '', '');

// returns 'cde'
subString('abcdeg', 2, 5);
```

> NOTE: All function names are camelCased.

Prior to PHP 5.6 this is not possible. So you can do this instead:

```
// Import the string class
use Gears\String as Str;

// returns true
Str::contains('this is a test', 'test');

// returns 'this is a test'
Str::between('this is a test', '', '');

// returns 'cde'
Str::subString('abcdeg', 2, 5);
```

**The factory method:** You may wish to use the factory method to initiate a new Gears\\String object. When you do, please note how the subsequent method call signature changes. You no longer need to provide the string to be performed on as the first argument. This is automatically done for you. Here is an example:

```
// using the factory method - returns true
Str::s('This is a test')->contains('test');

// Method chaining is possible - returns 'this is a test'
Str::s('this is a test')
	->between('', '')
	->between('', '');
```

If an array is returned for example when using the match method, the array will be an array of Gears\\String instances not simple PHP strings.

```
foreach (Str::s('I am going to perform a test')->match('/ \w /') as $match)
{
	if ($match->contains('a'))
	{
		echo 'we found the letter a';
	}
}
```

> NOTE: Using the procedural API will only ever return standard PHP strings unlike the above.

Laravel Integration
-------------------

[](#laravel-integration)

*Gears\\String* has been designed as functionally compatible to the *Laravel Str*class. Thus if you want you can completely swap out `Illuminate\Support\Str` for `Gears\String`.

To do so in the file `/app/config/app.php` replace the following line:

```
'Str' => 'Illuminate\Support\Str',
```

with:

```
'Str' => 'Gears\String',
```

Credits
-------

[](#credits)

Thanks to *alecgorge* for the inspiration, I have taken his methods re-factored them slightly and added a few of my own methods, into the mix.

Additionally all methods in the class `Illuminate\Support\Str`provided by Laravel. Have been integrated into `Gears\String`.

---

Developed by Brad Jones -

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~125 days

Recently: every ~181 days

Total

16

Last Release

2797d ago

Major Versions

v0.6.0 → v1.0.0-RC12016-04-13

PHP version history (2 changes)v0.1PHP &gt;=5.3

v1.0.0-RC1PHP ^5.4 || ^7.0

### Community

Maintainers

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

---

Top Contributors

[![brad-jones](https://avatars.githubusercontent.com/u/2754772?v=4)](https://github.com/brad-jones "brad-jones (3 commits)")

---

Tags

stringmanipulation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/el-gitto-junior-string/health.svg)

```
[![Health](https://phpackages.com/badges/el-gitto-junior-string/health.svg)](https://phpackages.com/packages/el-gitto-junior-string)
```

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M711](/packages/doctrine-inflector)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[voku/stringy

A string manipulation library with multibyte support

1783.8M19](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

234.5M14](/packages/statamic-stringy)[opis/string

Multibyte strings as objects

7120.9M7](/packages/opis-string)

PHPackages © 2026

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