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

Support Laravel Package

cartalyst/support

Common support utilities for Cartalyst PHP/Laravel packages: helpers, contracts, traits, service providers, and base classes that streamline package development and shared functionality across components.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing via Composer: composer require cartalyst/support. This package is intentionally light and non-intrusive—no service provider registration needed. Jump straight into using its traits (e.g., HasAttributes, HasArrayAccess, Str) and helper functions (e.g., array_get, array_set, camel_case, snake_case) in any PHP class or global scope. A common first use case is enhancing plain PHP objects with HasAttributes to get convenient magic __get()/__set() and getAttributes() methods—ideal for DTOs or lightweight domain objects.

Implementation Patterns

  • DTO Enhancement: Apply the HasAttributes trait to value objects for safe, encapsulated property access and modification without boilerplate getters/setters.
  • Array utilities: Use array_get()/array_set() with dot notation (e.g., array_get($data, 'user.profile.name')) for deeply nested array operations in config-heavy or API payload workflows.
  • String helpers: Call functions like str_before(), str_after(), slugify(), or class_basename() directly—no Facades required.
  • Arrayable/Jsonable compliance: Use HasArrayAccess to make classes seamlessly integrate with Laravel’s ToArray/ToJson ecosystem—even outside Laravel projects.
  • Trait composition: Mix HasAttributes + HasArrayAccess + HasClassMethods for maximal flexibility in models or service classes.

Gotchas and Tips

  • No autoloading magic: Helpers are not auto-imported—either use function Cartalyst\Support\array_get; at the top of the file or call via fully qualified name.
  • Trait method conflicts: HasAttributes defines __get/__set—ensure your class doesn’t already rely on magic methods or use @method annotations to avoid IDE confusion.
  • Strict typing: These traits assume keys exist; use array_has() or null-coalescing checks when processing untrusted input.
  • Laravel integration optional but powerful: Works out of the box in Laravel apps (and even non-Laravel apps), but especially synergizes with Laravel collections, configs, and validation.
  • Extensibility: The package’s Str class is fully extendable—override or extend it via your own helper layer if custom string operations are needed (check Str::extend() in docs).
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