PHPackages                             darkghosthunter/larahelp - 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. darkghosthunter/larahelp

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

darkghosthunter/larahelp
========================

Supercharge your Laravel projects with useful global helpers.

v3.2.0(4y ago)481232MITPHPPHP ^8.0

Since Jun 7Pushed 4y agoCompare

[ Source](https://github.com/DarkGhostHunter/Larahelp)[ Packagist](https://packagist.org/packages/darkghosthunter/larahelp)[ Docs](https://github.com/darkghosthunter/larahelp)[ Fund](https://paypal.me/darkghosthunter)[ Fund](https://ko-fi.com/DarkGhostHunter)[ RSS](/packages/darkghosthunter-larahelp/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (7)Versions (14)Used By (0)

[![Regine Tholen - Unsplash (UL) #ojGvj7CE5OQ](https://camo.githubusercontent.com/cbcb9edf9761f3e0dad95bf08a5aa144bfb360e363a518a6ecef8c1bff88d5d6/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313537343234363931353332372d3863663530316439343735373f69786c69623d72622d312e322e3126697869643d65794a6863484266615751694f6a45794d446439266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)](https://camo.githubusercontent.com/cbcb9edf9761f3e0dad95bf08a5aa144bfb360e363a518a6ecef8c1bff88d5d6/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313537343234363931353332372d3863663530316439343735373f69786c69623d72622d312e322e3126697869643d65794a6863484266615751694f6a45794d446439266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)

[![Latest Stable Version](https://camo.githubusercontent.com/ea546cf15c9837611597e8039fd307b1dfcd5f105fdef9081cbd42368543758a/68747470733a2f2f706f7365722e707567782e6f72672f6461726b67686f737468756e7465722f6c61726168656c702f762f737461626c65)](https://packagist.org/packages/darkghosthunter/larahelp) [![License](https://camo.githubusercontent.com/2ec2ce95591ad9e2d441089e6bb91e25872d84ba07c4f1e2272f811a086e8275/68747470733a2f2f706f7365722e707567782e6f72672f6461726b67686f737468756e7465722f6c61726168656c702f6c6963656e7365)](https://packagist.org/packages/darkghosthunter/larahelp)[![](https://camo.githubusercontent.com/9d6fbae010be656358984a502e0be0b43f38feb2fc851c792d66e0b2c50124f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f6c61726168656c702e737667)](https://camo.githubusercontent.com/9d6fbae010be656358984a502e0be0b43f38feb2fc851c792d66e0b2c50124f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f6c61726168656c702e737667)[![](https://github.com/DarkGhostHunter/Larahelp/workflows/PHP%20Composer/badge.svg)](https://github.com/DarkGhostHunter/Larahelp/workflows/PHP%20Composer/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/b4b327106e2a21e783be319352332abc0d7a9f16f8d15ef1ebe5da8166568126/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4461726b47686f737448756e7465722f4c61726168656c702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/DarkGhostHunter/Larahelp?branch=master)

Larahelp
========

[](#larahelp)

Supercharge your Laravel projects with more than 25 useful global helpers.

Requisites
----------

[](#requisites)

- Laravel 8.x or later
- PHP 8.0 or later

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

[](#installation)

You can install the package via composer:

```
composer require darkghosthunter/larahelp
```

> This package is focused on the backend. If you want views helpers, I recommend you to use [custom Blade directives](https://laravel.com/docs/blade#extending-blade) instead.

Usage
-----

[](#usage)

This package includes helpful global helpers for your project make almost anything into beautiful *one liners*:

[app\_call](#app_call)[in\_development](#in_development)[route\_is](#route_is)[call\_existing](#call_existing)[logged\_in](#logged_in)[shadow](#shadow)[created](#created)[methods\_of](#methods_of)[sleep\_between](#sleep_between)[data\_update](#data_update)[missing\_trait](#missing_trait)[taptap](#taptap)[delist](#delist)[none\_of](#none_of)[undot\_path](#undot_path)[diff](#diff)[object\_assign](#object_assign)[until](#until)[dot\_path](#dot_path)[ok](#ok)[user](#user)[enclose](#enclose)[period](#period)[weekend](#weekend)[files](#files)[period\_from](#period_from)[weekstart](#weekstart)[has\_trait](#has_trait)[pipe](#pipe)[which\_of](#which_of)[hashy](#hashy)[remember](#remember)[yesterday](#yesterday)[in\_console](#in_console)[route\_is](#route_is)### `app_call()`

[](#app_call)

Executes a callable using the application Container.

```
$result = app_call('\App\MyService\Service@createSomething');
```

### `call_existing()`

[](#call_existing)

Calls a dynamic method or macro if it exists in the object instance. It supports macros and static methods.

```
class Something {
    public function foo() {
        return 'bar';
    }
}

call_existing(new Something, 'bar'); // null

call_existing(new Something, 'foo'); // "bar"
```

### `created()`

[](#created)

Return an HTTP 201 response (OK, Created), with optional content.

```
public function store(Request $request): Response
{
    // ...

    return created([$post->getKeyName() => $post->getKey()];
}
```

### `data_update()`

[](#data_update)

Updates an item of an array or object using a callback that receives it.

```
$array = [
    'foo' => [
        'bar' => null
    ]
];

data_update($array, 'foo.bar', function ($value) {
    if ($value === null) {
        return 'baz';
    }
})

// [
//     'foo' => [
//         'bar' => 'baz'
//     ]
// ];
```

> The value will be updated regardless if the key doesn't exists.

### `delist()`

[](#delist)

Returns the values of the array, so these can be listed into variables. It accepts an optional offset to remove a given number of first keys.

```
$array = [
    'foo'  => 'bar',
    'baz'  => 'qux',
    'quux' => 'quuz',
]

[$baz, $quux] = delist($array, 1);
```

### `diff()`

[](#diff)

Returns the difference between two dates in seconds or any other given unit.

```
$seconds = diff('now', '15th may');

$minutes = diff('today', now())
```

### `dot_path()`

[](#dot_path)

Transforms a relative path into dot notation.

```
$path = dot_path('files/user_id_312/videos/');

// files.user_id_312.videos
```

> This does not validate file paths. You should append the filename to the dot-path manually.

### `enclose()`

[](#enclose)

Wraps a value or callable into a Closure, if it's not already callable.

```
$enclosed = enclose('foo');

$enclosed();

// "foo"
```

### `files()`

[](#files)

Returns the local Filesystem helper, or a list of files in a path.

```
$content = files()->get('text.txt');
```

### `has_trait()`

[](#has_trait)

Checks recursively if the object is using a single trait.

```
trait Child {
    // ..
}

trait Parent {
    use Child;
    // ..
}

class Foo {
    use Parent;
}

has_trait(Foo::class, Child::class);

// true
```

### `hashy()`

[](#hashy)

Creates a small BASE64 encoded MD5 hash from a string for portable checksum.

This is very useful to hash large walls of texts, or even files, while compressing the 128-bit hash into a 24-character string.

```
$hash = hashy('This is a hashable string');

// "TJYa8+63dRbdN6w44shX1g=="
```

You can use the same function to compare the hashable string with a hash to note if it was modified.

```
hashy('This is a hashable string', 'TJYa8+63dRbdN6w44shX1g==');

// true

hashy('This is a hashable string!', 'TJYa8+63dRbdN6w44shX1g==');

// false
```

### `in_console()`

[](#in_console)

Check if the application is running in console, like when using Artisan or PHPUnit.

```
if (in_console()) {
    return "We're in console";
}
```

It also accepts a callable that will be executed if the condition is true.

```
$result = in_console(fn() => 'foo');

// "foo"
```

### `in_development()`

[](#in_development)

Check if the application is running in development environments: `dev`, `development` or `local`

```
if (in_development()) {
    return "Do anything, it doesn't matter!";
}
```

It also accepts a callable that will be executed if the condition is true.

```
$result = in_development(fn() => 'foo');

// "foo"
```

### `logged_in()`

[](#logged_in)

Executes a single callback while the user is logged in.

It basically logs in and logs out an user while executing the callback, which can be useful to do on guest routes.

```
use App\Models\User;

$user = User::find(1);

$post = logged_in($user, function (User $user) {
    return $user->post()->create([
        // ..
    ]);
});
```

> It will throw an exception if there is already a user logged in.

### `methods_of()`

[](#methods_of)

Returns a collection of all public methods from a given class or object.

```
use Illuminate\Support\Collection;

$methods = methods_of(Collection::class)

return $methods->has('make');

// true
```

### `missing_trait()`

[](#missing_trait)

Checks recursively if the object is not using a trait.

```
trait Parent {
    // ..
}

class Foo {
    use Parent;
}

missing_trait(Foo::class, Child::class);

// true
```

### `none_of()`

[](#none_of)

Checks if none of the options compared to a subject, or called with it, returns something truthy.

```
$subject = 'foo';

none_of('foo', ['bar', 'baz', 'qux']);

// false
```

Using a callable, it will receive the subject and the key being compared.

```
$subject = 'foo';

none_of('foo', ['bar', 'baz', 'qux'], fn ($subject, $compared) => $subject === $compared);

// false
```

### `object_assign()`

[](#object_assign)

Assigns an array of values to an object, recursively, using dot notation.

```
$object = new stdClass();

object_assign($object, ['foo' => 'bar']);

echo $object->foo; // "bar"
```

### `ok()`

[](#ok)

Returns an HTTP 204 response (OK, No Content).

```
public function send(Request $request)
{
    // ...

    return ok();
}
```

### `period()`

[](#period)

Returns the period of a given start and end or interval. Periods are extremely useful to get multiple dates based on a start, end, a given time between each occurrence.

The most common way to create a period is defining the start, the number of occurrences, and the interval amount.

```
$periods = period('now', 4, '15 minutes');
```

Alternatively, you can specify a start, and end, and the interval of time until that end.

```
$period = period('today', 'last day of this month', '3 days');
```

Once you do, you can iterate each moment of time with a `foreach` loop.

```
foreach (period('today', 'last day of this month', '3 days') as $datetime) {
    echo $datetime->toDateTimeString();
}

// 2015-07-21 00:00:00
// 2015-07-24 00:00:00
// 2015-07-27 00:00:00
// 2015-07-30 00:00:00
```

### `period_from()`

[](#period_from)

Returns the next or previous period from given date, exclusive by default.

This is very handy to know when the next or previous moment from a given datetime, like the current time.

```
$period = period('2015-07-06 00:00:00', '2015-07-26 00:00:00', '1 week');

period_from($period, '2015-07-13');

// 2015-07-13
```

The function can also check the previous date by setting `$after` to `false`.

```
$period = period('2015-07-06 00:00:00', '2015-07-26 00:00:00', '1 week');

period_from($period, '2015-07-06');

// 2015-07-13
```

> Dates compared are exclusive. In include the date as inclusive, set `$inclusive` to `true`.

### `pipe()`

[](#pipe)

Sends an object through a pipeline.

```
pipe(10, [
    fn($integer, $next) => $next($integer + 10);
    fn($integer, $next) => $next($integer - 5);
])

// 15
```

### `remember()`

[](#remember)

Retrieves an item from the cache, or stores a default value if the item doesn't exist.

```
remember('foo', 60, function() {
    return 'bar';
})
```

If no `ttl` is set, and rather a callback is issued as second parameter, it will be stored forever.

```
remember('foo', function () {
    return 'bar';
})
```

It supports atomic locks, which are created using the same name key. It will lock the key by a given seconds, while also waiting for the same amount of time.

```
remember('foo', 60, function() {
    return 'bar';
}, 20);
```

This can be useful to avoid cache data-races, where multiple processes run the same callback because the cache key is not filled yet.

### `route_is()`

[](#route_is)

Determine whether the current route's name matches the given patterns.

```
if (route_is('dahsboard.*')) {
    return 'You are in the dashboard';
}
```

### `shadow()`

[](#shadow)

Calls a method on an object if it exists, or returns false. It supports Macros.

```
if ($rendered = shadow($mayRender, 'render')) {
    return $rendered;
}

return response((string)$mayRender);
```

### `sleep_between()`

[](#sleep_between)

Runs a callback while sleeping between multiple executions, returning a Collection of all results.

```
use App\Models\User;

sleep_between(3, 1000, fn() => User::query()->inRandomOrder()->value('name'))

// [
//     'john',
//     'michel',
//     'maria',
// ]
```

### `taptap()`

[](#taptap)

Call the given Closure with the given value then return the value, twice.

```
use App\Models\User;
use App\Notifications\Message;

return taptap(User::find(1))->notify(new Message('Hello!'))->save();
```

### `undot_path()`

[](#undot_path)

Transforms a path from dot notation to a relative path.

```
$path = undot_path('files.user_id_312.videos');

// files/user_id_312/videos/
```

### `until()`

[](#until)

Returns the interval from a date until the desired date.

```
until('now', 'next month')->total('days');

// 25
```

### `user()`

[](#user)

Returns the currently authenticated user, if any.

```
user()?->name;

// "John Doe"
```

### `weekend()`

[](#weekend)

Returns the end of the week. It supports setting what day the week end.

```
weekend()->toDateTimeString();

// 2015-07-05 23:59:59

weekend('now')->toDateTimeString();

// 2015-07-13 23:59:59
```

### `weekstart()`

[](#weekstart)

Returns the end of the week. It supports setting what day the week starts.

```
weekstart()->toDateTimeString();

// 2015-06-28 00:00:00

weekstart('now')->toDateTimeString();

// 2015-07-06 00:00:00
```

### `which_of()`

[](#which_of)

Returns the key of the option which comparison or callback returns true.

```
$which = which_of('foo', [0 => 'baz', 1 => 'bar', 2 => 'foo'])

// 2
```

If the callback returns something truthy, that value will be used.

```
$which = which_of(
    'foo',
    ['baz', 'bar', 'foo'],
    fn($subject, $option) => $subject === $option ? 'cougar' : false)
);

// "cougar"
```

### `yesterday()`

[](#yesterday)

Returns the date for yesterday.

```
// 2015-07-12 17:30:00
yesterday();

// 2015-07-11 00:00:00
```

Missing a helper?
-----------------

[](#missing-a-helper)

If you have an idea for a helper, shoot it as an issue. PR with test and good code quality receive priority.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

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

Total

12

Last Release

1765d ago

Major Versions

v1.3.0 → v2.0.02021-03-18

v2.0.0 → v3.0.02021-08-12

PHP version history (3 changes)v1.0.0PHP ^7.2.15

v2.0.0PHP ^7.4||^8.0

v3.0.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![DarkGhostHunter](https://avatars.githubusercontent.com/u/5141911?v=4)](https://github.com/DarkGhostHunter "DarkGhostHunter (34 commits)")

---

Tags

helperslaravelphplaravelhelpersdarkghosthunter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darkghosthunter-larahelp/health.svg)

```
[![Health](https://phpackages.com/badges/darkghosthunter-larahelp/health.svg)](https://phpackages.com/packages/darkghosthunter-larahelp)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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