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
Getter Setter Accessor Bundle

Getter Setter Accessor Bundle Laravel Package

alexanevsky/getter-setter-accessor-bundle

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Getter Setter Accessor Bundle
How do I install this package in a Laravel project?
This package is designed as a Symfony bundle, so you’ll need to manually register it in `config/bundles.php` and wrap it in a Laravel service provider. Use Composer to install it via `composer require alexanevsky/getter-setter-accessor-bundle`, then configure it to work with Laravel’s DI container.
Does this package work with Laravel Eloquent models?
No, this package only works with objects that have explicitly defined getters/setters. Laravel Eloquent models use dynamic property access (e.g., `$model->name = 'John'`), which this package does not support. It’s better suited for legacy objects or DTOs with explicit methods.
Will this package slow down my Laravel application?
Yes, reflection-based property access is significantly slower than direct property access—up to 100x in high-frequency operations. Use this only for low-throughput scenarios like admin panels, not for API endpoints or bulk operations.
Can I use snake_case or camelCase property names interchangeably?
Yes, the package automatically converts between snake_case and camelCase. For example, `getValue('user_name')` and `getValue('userName')` will both work if the corresponding getter/setter exists.
How do I handle missing getters or setters?
The package throws exceptions if a getter or setter doesn’t exist. You can check for their existence first using `hasGetter()` or `hasSetter()` to avoid runtime errors, but this adds manual validation overhead.
Is this package compatible with Laravel’s dependency injection?
No, it’s built for Symfony’s DI container. You’ll need to create a custom Laravel service provider to integrate it, which may introduce conflicts or require additional configuration.
Can I use this for runtime form generation or dynamic validation?
Yes, this package is useful for generating forms or validation rules dynamically by inspecting available getters/setters. However, it’s less efficient than Laravel’s built-in accessors or traits like `Arrayable`.
What Laravel versions does this package support?
The package requires PHP 8.1+ and relies on Symfony components already included in Laravel. However, it’s not officially tested or documented for Laravel-specific use cases, so compatibility may vary.
Are there alternatives for dynamic property access in Laravel?
Yes, consider Laravel’s built-in accessors (e.g., `setAttribute()`), `Arrayable`, `Jsonable`, or traits like `Macroable`. These are optimized for Laravel and avoid reflection overhead, making them better for most use cases.
How do I mock getters/setters in PHPUnit tests?
Mocking reflection-based accessors is complex. You’ll need to create partial mocks or use dependency injection to replace the `GetterSetterAccessor` with a test double, which may require additional setup to avoid reflection errors.
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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime