browner12/helpers
browner12/helpers is a Laravel package offering convenient global helper functions for common tasks like array and string manipulation, URL generation, HTML formatting, and more, reducing boilerplate and keeping your code concise and readable.
browner12/helpers is a small utility package that adds a set of global PHP helper functions for string and array manipulation on top of what Laravel already ships. There is no facade, no published config, and no service provider to register — the functions are loaded through Composer's files autoload, so they exist everywhere the moment the package is installed.
composer require browner12/helpers:^3.7
If you added it manually to composer.json, run composer dump-autoload afterwards so the files autoload entry is picked up.
Where to look first:
vendor/browner12/helpers/composer.json — confirm the autoload.files entry; that is the whole integration.vendor/browner12/helpers/src/ — the source is the documentation. Each helper is a short function; read the signature before using it rather than guessing from the name.First use case: you have a controller or importer that is doing substr/strpos gymnastics to pull a value out of a formatted string, or a report that groups rows by a key with a hand-rolled foreach. Replace that block with the relevant helper and delete the loop. That is the entire value proposition: fewer bespoke loops, less off-by-one index math.
Because v3.7.0 explicitly adds Laravel 12.x compatibility, this is a safe addition on a Laravel 12 / PHP 8.2+ application. Laravel 12 requires PHP 8.2, and the v3 line targets modern PHP, so there is no version juggling to do.
Use them at the edges, not in your domain layer. Helpers are procedural and global; keep them in controllers, form requests, Blade views, console commands, importers, and seeders. If a helper encodes real business rules, wrap it:
final class SkuParser
{
public static function extractFamily(string $sku): ?string
{
return str_between($sku, '[', ']'); // swap-in point if the helper ever goes away
}
}
That one-line wrapper makes the dependency replaceable and gives you a place to add tests and types.
String parsing / extraction. Use the str_* helpers where you would otherwise write substr($s, strpos($s, $a) + strlen($a), strpos($s, $b) - ...). Typical fits: scraping a token out of a log line, pulling a segment out of a delimited code (SKU, tracking number, slug), inserting a segment at a fixed offset.
Array shaping in reports and exports. The array helpers (transpose, group-by-key, sort-by-key style operations) are most useful in CSV/XLSX export builders and dashboard aggregations, where you are reshaping a Collection result into a column-oriented structure before handing it to a writer. Converting to an array, reshaping, then collect()-ing back is often clearer than chained map/reduce.
Blade and one-off admin screens. Global functions are callable directly in Blade without @php imports, which makes them convenient for display formatting in admin-only views. Avoid them in customer-facing views you may later extract into a package — global function calls do not travel well.
Testing. Nothing to configure: the functions are available inside PHPUnit/Pest tests. Cover the wrapper class from the pattern above rather than the vendor function, and add one integration-style assertion that the function exists (function_exists('str_between')) if you depend on it in a critical path.
Upgrade path. Pin with ^3.7 and let Composer resolve. Minor releases in this package have historically been additive/compatibility-only (v3.7.0 is a Laravel 12 compatibility bump plus a changelog entry), so composer update browner12/helpers is a low-risk operation — but run your test suite anyway, since a widened illuminate/support constraint can pull a newer framework version into the lockfile.
app/helpers.php) declares the same function name, PHP throws Cannot redeclare ...() at boot. Before adding, grep your codebase and vendor/ for the names you intend to use. Guarding your own copies with if (! function_exists('x')) does not help if the vendor file is the unguarded one — it will still fatal on collision.Illuminate\Support\Str and Arr (and the Str fluent API). Several helpers here now have a first-party equivalent. For new code, prefer Str::/Arr:: when an equivalent exists and reserve this package for the functions Laravel genuinely does not cover — otherwise you accumulate a dependency you cannot easily drop later.config/helpers.php to appear.files autoload runs on every PHP process, including queue workers, Artisan commands and Octane workers. The cost is trivial (a handful of function declarations), but it means you cannot conditionally load it per environment — and it also means a syntax error in the package breaks the entire app, including artisan.static variable inside a helper call site to "make it faster", you have introduced cross-request state in a long-lived worker. Don't.composer show browner12/helpers to confirm it is installed in this environment (a --no-dev deploy should still install it if it is in require, not require-dev); (2) check vendor/composer/autoload_files.php for the entry; (3) composer dump-autoload -o; (4) confirm you are not inside a namespaced file calling it as Helpers\str_between.@method annotations, so PhpStorm will flag them as undefined and PHPStan will complain at higher levels. Either add a small _ide_helper.php-style stub file listing the signatures you use, or route everything through the wrapper classes recommended above — the wrapper approach solves completion, refactoring and static analysis in one move.How can I help you explore Laravel packages today?