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.
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