PHPackages                             calebporzio/awesome-helpers - 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. calebporzio/awesome-helpers

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

calebporzio/awesome-helpers
===========================

Helper functions I find super-duper handy

v2.5.0(5y ago)625122.6k↑27%50[5 PRs](https://github.com/calebporzio/awesome-helpers/pulls)1MITPHPPHP &gt;=7.3

Since Feb 1Pushed 5y ago11 watchersCompare

[ Source](https://github.com/calebporzio/awesome-helpers)[ Packagist](https://packagist.org/packages/calebporzio/awesome-helpers)[ Docs](https://github.com/calebporzio/awesome-helpers)[ RSS](/packages/calebporzio-awesome-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (1)

A collection of awesome helpful functions for Laravel
=====================================================

[](#a-collection-of-awesome-helpful-functions-for-laravel)

[![Travis CI status image](https://camo.githubusercontent.com/2b7fe93383c6c53f8e274f75450815177554ab7aa9873108a83ddba50fdabec9/68747470733a2f2f7472617669732d63692e636f6d2f63616c6562706f727a696f2f617765736f6d652d68656c706572732e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/2b7fe93383c6c53f8e274f75450815177554ab7aa9873108a83ddba50fdabec9/68747470733a2f2f7472617669732d63692e636f6d2f63616c6562706f727a696f2f617765736f6d652d68656c706572732e7376673f6272616e63683d6d6173746572)

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

[](#installation)

```
composer require calebporzio/awesome-helpers
```

Helpers
-------

[](#helpers)

**carbon**

Shortcut for: `new Carbon` or `Carbon::parse()`

```
carbon('One year ago');
```

**chain**

Makes an ordinary object chainable.

```
chain(new SomeClass)
    ->firstMethod()
    ->secondMethod()
    ->thirdMethod();

// You can use the "carry" constant to pass the result of one method into the other:
chain(new Str)->singular('cars')->ucfirst(carry)();
// Returns "Car"
// Also, you can grab the result of the chain by trailing
// a "()" on the end of it. (Thanks to Taylor Otwell for these two additions)
```

**connection**

Run callback under a different database connection.

```
$tenantPostIds = connection('tenantdb', function () {
    return Post::pluck('id');
});
```

**dump\_sql**

Returns sql query with bindings data.

```
dump_sql(\DB::table('users')->where('email', "blaBla")->where('id', 1));
// returns "select * from `users` where `email` = 'blaBla' and `id` = 1"
```

**faker**

Shortcut for: `$faker = Faker\Factory::create()`

```
faker()->address; // returns random, fake address
faker('address'); // alternate syntax
```

**user**

A shortcut for `auth()->user()`

```
user()->posts()->create([...]);
```

**money**

```
echo money(12); // echoes "$12.00"
echo money(12.75); // echoes "$12.75"
echo money(12.75, false); // echos "$13"
echo money(12.75, true, 'en_GB'); // echos "£12.75"
// Note: unless specified otherwise, money() will detect the current locale.
```

**ok**

Shortcut for `response('', 204)`. When you don't have anything to return from an endpoint, but you want to return success.

```
return ok();
```

**stopwatch**

Returns the amount of time (in seconds) the provided callback took to execute. Useful for debugging and profiling.

```
stopwatch(function () {
    sleep(2);
}); // returns "2.0"
```

**str\_between**

Returns string between second argument

```
str_between('--thing--', '--'); // returns "thing"
str_between('[thing]', '[', ']'); // returns "thing"

Str::between('--thing--', '--'); // returns "thing"
Str::between('[thing]', '[', ']'); // returns "thing"
```

**str\_extract**

Returns capture groups contained in the provided regex pattern.

```
str_extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"

Str::extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"
```

**str\_match**

Checks the provided string against the provided regex pattern.

```
str_match('Jan-01-2019', '/Jan-.*-2019/'); // returns true
str_match('foo bar baz', 'bar'); // returns true

Str::match('Jan-1-2019', '/Jan-(.*)-2019/'); // returns true
```

**str\_validate**

A simple way to use validate a string using Laravel's built-in validation system.

```
str_validate('calebporzio@aol.com', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]

Str::validate('calebporzio@aol.com', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]
```

**str\_wrap**

```
str_wrap('thing', '--'); // returns "--thing--"

Str::wrap('thing', '--'); // returns "--thing--"
```

**swap**

This function swaps the values of two variables.

```
$startDate = '2040-01-01';
$endDate = '2020-01-01';

if ($endDate < $startDate) {
    swap($startDate, $endDate);
}

echo $startDate; // prints "2020-01-01"
echo $endDate; // prints "2040-01-01"
```

**tinker**

Kind of like `dd()`, but will open an `artisan tinker` terminal session with the variables you passed in, so you can play around.

```
$somethingYouWantToDebug = new StdClass;
tinker($somethingYouWantToDebug);
```

Am I missing an awesome helper function?
----------------------------------------

[](#am-i-missing-an-awesome-helper-function)

Submit a PR or issue with helper functions you use or ideas you have for others!

TTFN, Caleb

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 54.9% 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 ~44 days

Recently: every ~133 days

Total

17

Last Release

1944d ago

Major Versions

v1.3 → v2.02019-03-04

PHP version history (2 changes)v1.0PHP ^7.1

v2.5.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/4608292025df3cf1d9db20c0484c7d0a3542e9a63fc681fae175e0233f1c250a?d=identicon)[calebporzio](/maintainers/calebporzio)

---

Top Contributors

[![calebporzio](https://avatars.githubusercontent.com/u/3670578?v=4)](https://github.com/calebporzio "calebporzio (45 commits)")[![CupOfTea696](https://avatars.githubusercontent.com/u/7327050?v=4)](https://github.com/CupOfTea696 "CupOfTea696 (8 commits)")[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (7 commits)")[![nullthoughts](https://avatars.githubusercontent.com/u/11416468?v=4)](https://github.com/nullthoughts "nullthoughts (4 commits)")[![adrianspacely](https://avatars.githubusercontent.com/u/3690710?v=4)](https://github.com/adrianspacely "adrianspacely (3 commits)")[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (3 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![TeeJay-Codes](https://avatars.githubusercontent.com/u/3678670?v=4)](https://github.com/TeeJay-Codes "TeeJay-Codes (2 commits)")[![repat](https://avatars.githubusercontent.com/u/516807?v=4)](https://github.com/repat "repat (2 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![lucasMesquitaBorges](https://avatars.githubusercontent.com/u/42281497?v=4)](https://github.com/lucasMesquitaBorges "lucasMesquitaBorges (1 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (1 commits)")[![timacdonald](https://avatars.githubusercontent.com/u/24803032?v=4)](https://github.com/timacdonald "timacdonald (1 commits)")[![ChanningDefoe](https://avatars.githubusercontent.com/u/46541358?v=4)](https://github.com/ChanningDefoe "ChanningDefoe (1 commits)")

---

Tags

calebporzioawesome-helpers

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/calebporzio-awesome-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/calebporzio-awesome-helpers/health.svg)](https://phpackages.com/packages/calebporzio-awesome-helpers)
```

###  Alternatives

[heyday/silverstripe-hashpath

Hash path provides a function in SilverStripe templates which given a path to an asset returns a path including a hash of the asset

1475.3k](/packages/heyday-silverstripe-hashpath)

PHPackages © 2026

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