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.
hamzi/corewatch
minionfactory/raw-hydrator
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