Weave Code
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

ralphjsmit/laravel-helpers

A handy collection of Laravel helper functions to simplify everyday tasks. Adds pragmatic utilities for strings, arrays, paths, and common framework workflows, aiming to reduce boilerplate and keep your app code clean and consistent.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require ralphjsmit/laravel-helpers. No service provider or config publishing is required—helpers are auto-loaded via the package’s helpers.php file (PSR-4 autoloading in src/Helpers). The first use case is typically replacing verbose conditional checks with helpers like present() (returns formatted value if not null) or blank_or() (returns fallback for null/blank values), e.g. present($user->email) ?? 'No email'.

Implementation Patterns

  • Inline formatting: Use present(), number(), currency(), or truncate() directly in Blade or controllers to avoid @if/else chains and keep templates concise.
  • Null-safe transformations: Replace ternary null-checks with blank_or($value, 'default') or filled_or($value, 'fallback').
  • Array/Collection shortcuts: Leverage array_get_path($array, 'user.profile.name') for nested access or array_only_keys($array, ['name', 'email']) for filtering without array_filter boilerplate.
  • Validation helpers: Integrate unique_without() (for validation rules excluding current model) directly in request validation.
  • Team consistency: Commit common helper usage in style guides—e.g., “always use starts_with($str, $prefix) instead of Str::startsWith() for brevity in internal code.”

Gotchas and Tips

  • Helpers are global functions—avoid naming conflicts with existing helpers (e.g., Laravel’s str_replace_first). This package extends Laravel helpers but doesn’t override them.
  • Some functions behave differently from PHP native equivalents: e.g., blank() considers 0, '0', '', and [] as blank, while empty() does not. Always check the docblock or tests if behavior is ambiguous.
  • Not all helpers support PHP 8.0–8.4 uniformly—review src/Helpers/ for signature compatibility (e.g., typed returns using |null/|false).
  • To extend: add custom helpers in app/helpers.php, but do not rely on this package for custom logic—reserve it for standardized small utilities only.
  • For debugging: use dd_safe() or dump_safe() to avoid issues with circular references or objects that can’t be serialized.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport