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

Utils Laravel Package

laragraph/utils

Laravel utilities for building GraphQL servers: shared primitives and helpers used by GraphQL packages. Install via Composer and use as a lightweight foundation for SDL-first (Lighthouse) or code-first (graphql-laravel) setups.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by requiring the package via Composer: composer require laragraph/utils. No service provider or config file is needed—it’s designed to be auto-discovered via PHP’s function autoloading. The package ships with a small, curated set of globally available helper functions (e.g., str_starts_with_any(), array_pull_first(), array_dot_pluck()) and a few lightweight trait-based utilities. Your first use case should be replacing ad-hoc string/array logic in controllers or services—look for patterns like manual explode()/join() chains or repetitive null-coalescing. For example, replace isset($data['key']) ? $data['key'] : 'default' with Arr::get($data, 'key', 'default') if the Arr helper is included, or use the provided data_get_default() if available. Check the src/helpers.php file for a full list of exported functions—they’re namespaced-friendly and won’t conflict with Laravel’s existing helpers.

Implementation Patterns

  • Replace conditional boilerplate: Use helpers like str_between($haystack, $start, $end) to extract substrings cleanly, or arr_filter_nulls() to sanitize request data before validation.
  • Uniform array processing: Leverage array_flat_pluck() for nested array extraction or array_group_with_key() to build associative groupings without verbose loops.
  • Laravel-integrated flows: Pair helpers with Eloquent—for instance, use str_slug_safe() to generate URL slugs while ensuring uniqueness without custom validation logic.
  • Trait-based enrichment: Apply traits like HasUniqueSlug to models to inject shared slug generation and validation logic, avoiding duplication across models.
  • Request validation shortcuts: Wrap commonly used rules in helper classes (e.g., Validation::emailOrUtmSource()) to centralize and standardize input rules across controllers.

Gotchas and Tips

  • No config caching: Since helpers are autodiscovered via composer.json’s files autoloading, avoid using them inside config files—they won’t be available during config:cache.
  • Collision awareness: Though MIT-licensed and lightweight, confirm no name collisions with your app’s existing helper functions or other packages—use \laragraph\utils\ fully qualified namespace when ambiguous.
  • Testing helpers: Helper functions are not mockable, so isolate logic in service classes during unit tests rather than calling them directly.
  • Extension points: Create your own app-specific helpers in app/Support/helpers.php, and list it in composer.json under autoload.files after laragraph/utils to ensure precedence.
  • Version stability: With a 2026 release date (future-dated), assume this is a stable, low-maintenance utility set—but verify changelog frequency. Since it’s small (21 stars), expect minimal breaking changes and document any overrides explicitly.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai