The illuminate/support package is foundational to Laravel and provides essential helper classes, functions, and utilities used daily by developers. It’s not meant to be used in isolation but is automatically included when you install Laravel. To start leveraging it:
laravel new app or use an existing Laravel project).composer require illuminate/support.Str, Arr, Optional, SnakeCase, CamelCase) globally and via facades.Str::slug('Hello World!') or Arr::divide(['foo' => 'bar']) anywhere in your app — these helpers are auto-loaded.Check the Laravel documentation on helpers for immediate, common use cases.
collect() helper with methods like map, filter, pipe, and tap for chaining data transformations.
$result = collect($users)
->map(fn($u) => $u->name)
->filter(fn($name) => strlen($name) > 3)
->values();
Conditionable trait (used in Str, Arr, etc.) for fluent conditionals.
return Str::of($slug)
->when($appendId, fn($str) => $str->append('-' . $id))
->when($uppercase, fn($str) => $str->upper());
Str, Arr, or custom classes using Macroable.
Str::macro('reverseWords', fn($string) => implode(' ', array_reverse(explode(' ', $string))));
echo Str::reverseWords('one two three'); // "three two one"
Optional for null-safe access, Str for multibyte string manipulation, and Str::of() for fluent string operations.Str methods respect multibyte (via mbstring), but array_* helpers (e.g., array_camel_case) don’t exist — use Arr::camel() instead.LazyCollection lives in illuminate/support, it’s only useful when chaining large datasets (e.g., from DB queries). Use LazyCollection::make(fn() => $generator) to avoid memory bloat.helpers.php — don’t call require manually. Avoid aliasing core helpers in namespaces.Str or Arr behavior (e.g., new flags in Str::plural()). Check release notes for breaking changes.dump($collection) or dd(Str::of($str)->trim()->slug()) to inspect intermediate values in chains — Laravel’s dd understands these objects well.How can I help you explore Laravel packages today?