Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Helpers Laravel Package

rappasoft/laravel-helpers

rappasoft/laravel-helpers offers a practical collection of helper functions and classes for Laravel, including utilities for arrays, strings, dates, numbers, URLs, and more. It helps reduce repetitive boilerplate and speed up everyday application development.

View on GitHub
Deep Wiki
Context7

Getting Started

rappasoft/laravel-helpers is a gap-filler for Laravel's own helper set: it adds global array_* and str_* functions for the operations you keep writing inline (filter an array by callback and take the first match, forget a mix of nested and top-level keys, retry with a computed delay).

Install:

composer require rappasoft/laravel-helpers

Requirements as of v3.0.2: PHP 8.1+ with the ctype and mbstring extensions. There is no service provider and no config file to publish — the helpers are loaded through Composer's files autoload, so they are available immediately in controllers, models, jobs, Blade views, and artisan tinker.

Where to look first:

  1. The README's helper index — scan the two columns (array_*, str_*) once rather than reading it end to end. The value of this package is knowing what exists, not reading implementation.
  2. vendor/rappasoft/laravel-helpers/src/ — each helper is a small, self-contained file; reading a signature is faster than guessing at edge-case behavior.
  3. The test suite, if you need to confirm a corner case (243 assertions across 107 tests, green on 8.1–8.5).

A good first use case, and the one that sells the package:

// Before: collect()->first(fn ($x) => ...) or a manual foreach
$firstActive = array_value_first(
    array_where($users, fn ($user) => $user['active']),
    ['name' => 'none'] // default
);

That idiom — array_where() to filter, array_value_first()/array_value_last() to pick — replaces a lot of collect() churn in code paths where you deliberately want to stay in plain-array land (payload shaping, API resources, config manipulation, queue job data).

Implementation Patterns

Array pipelining instead of collections. The package's sweet spot is code that must not allocate a Collection: request payload normalization, config array merging, transforming data before json_encode, or anything inside a hot loop. Compose array_where() → array_pluck() → array_value_first() and keep the data as arrays the whole way through.

Nested mutation with mixed key depth. array_forget() and array_except() accept dot-notation nested keys alongside top-level ones. v3.0.2 specifically fixes a bug where deleting a nested key could drop unrelated top-level siblings — so if you use this for "strip sensitive fields before logging," upgrade and add a regression test of your own:

$safe = array_except($payload, ['password', 'user.token', 'card.cvv']);

value() with argument forwarding. The package's value() forwards closure arguments, so you can use it as a tiny inline strategy/resolver without reaching for app()->call():

$price = value($pricing, $product, $quantity); // closure receives both args

Use it for defaulting patterns where the fallback depends on context rather than being a constant.

retry() with dynamic backoff. Delay callbacks now receive correct attempt counts and arguments in v3.0.2. The day-to-day pattern is exponential or jittered backoff driven by the attempt number:

retry(3, fn (int $attempt) => $attempt * 250, fn () => $client->send($request));

If you previously worked around off-by-one attempt counts or ignored callback args, delete those workarounds on upgrade — they will now double-count.

String helpers as Str:: shortcuts. Reach for the global str_* functions in Blade templates and string-heavy mapping code where Str::studly() reads worse inline. In application code with a use Illuminate\Support\Str; already in place, prefer Str:: for IDE discoverability and keep the global helpers for views and one-liners.

Gotchas and Tips

PHP 8.5 will break callback-style array_first() / array_last() calls. This is the headline risk in v3.0.2. PHP 8.5 ships native array_first(array $array) and array_last(array $array) — array-only, no callback, no default. The package's callback/default signatures remain valid on 8.1–8.4 only. Before bumping your PHP version, grep for these two names and rewrite as:

$first = array_value_first(array_where($items, $callback), $default);
$last  = array_value_last(array_where($items, $callback), $default);

The failure mode is nasty: on 8.5 the call won't necessarily be a clean error, because a callback passed as a second argument to a native array-only function is a type error only if you're strict — the practical outcome is a confusing TypeError or silently wrong result in the middle of a request. Audit now, migrate later at your leisure, and standardize on array_value_first/array_value_last in new code so you're already 8.5-ready. The array_value_* variants are the forward-compatible choice on every supported PHP version.

Naming is inconsistent by design. array_value_first vs array_first in the same family is a smell worth internalizing early; keep a short cheat sheet in your team docs rather than assuming the name follows the pattern.

No namespace, high collision surface. These are global functions loaded via Composer files. Any other helper package (or a future Laravel release adding the same name) can collide, and the resulting error is a fatal "cannot redeclare" at boot — not at the call site. Check composer show for overlapping helper libraries before adding this to a mature app, and avoid re-declaring similar names in your own app/helpers.php.

Version pin matters. v3.0.2 fixes behavior in retry(), value(), array_forget(), and array_except() — all functions whose prior bugs fail quietly rather than loudly. Pin at ^3.0.2 and don't float on ^3.0.0 if you rely on any of those four.

Extension points are limited — treat it as a utility surface, not a framework. There is no service provider, no config, no facade, nothing to override. If you need different semantics, wrap the helper in your own function rather than expecting configuration. That's fine for a helpers package, but it means the migration path out (if the package is abandoned) is a mechanical copy of the functions you actually use — so keep your call sites identifiable via a grep-friendly convention, or wrap the ones you use most behind a single internal helper class.

Test coverage is asserted, not guaranteed for your edge cases. The release notes report a clean suite on 8.1–8.5 with dependency audits, which is a good signal, but these are global functions with no type-level contracts. Anywhere the difference between "returns null" and "returns the default" matters — cache reads, API responses — assert your assumption with a one-line test before shipping.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package