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

Setting Laravel Package

larapacks/setting

Lightweight Laravel settings manager that stores and retrieves key/value app configuration at runtime. Provides a clean API and helpers for persisting settings (including grouped/namespaced keys), with caching support for fast reads and easy integration into Laravel apps.

View on GitHub
Deep Wiki
Context7

Persistent Laravel Settings.

Frequently asked questions about Setting
How do I install larapacks/setting in a Laravel project?
Run `composer require larapacks/setting` to install the package. Then register the service provider in `config/app.php` under the `providers` array. The package includes a default migration for a settings table, which you’ll need to run with `php artisan migrate`.
Does this package support Laravel 10?
The package was last updated in March 2023 and is confirmed compatible with Laravel 9. While no explicit Laravel 10 support is stated, it should work with minimal adjustments, primarily checking `bootstrap/app.php` for service provider registration. Test thoroughly for any breaking changes.
Can I use Redis or another cache driver instead of the database for settings?
The package defaults to database persistence but leverages Laravel’s Cache facade for retrieval. You can configure it to use Redis or other cache drivers by setting the cache driver in `config/setting.php` or via environment variables, though the underlying storage remains database-backed by default.
How do I validate settings (e.g., enforce types or required fields)?
The package does not include built-in validation. You’ll need to implement custom validation logic, such as using Laravel’s Form Request validation or middleware to enforce types (e.g., integers, booleans) or required fields before accessing or updating settings.
What’s the best way to organize settings (e.g., namespaces or groups)?
Use dot notation for grouping, like `feature.flags.new_ui` or `payment.gateways.stripe`. The package supports this natively, and you can define default values in `config/setting.php` under a `groups` or `defaults` array for better organization.
How do I handle missing settings (e.g., return null vs. throw an exception)?
By default, the package returns `null` for missing settings. To enforce stricter behavior, configure a fallback in `config/setting.php` or wrap calls with `Setting::get('key', default_value)` or use `Setting::has('key')` to check existence before retrieval.
Can I use this package for feature flags or A/B testing?
Yes, the package is ideal for dynamic feature flags or A/B testing. Store flags as settings (e.g., `feature.new_ui.enabled`) and retrieve them at runtime with `Setting::get('feature.new_ui.enabled')`. Combine with caching for performance, e.g., `Setting::remember('key', 3600)` for hourly updates.
How do I test settings in PHPUnit?
Mock the `Setting` facade in your tests using Laravel’s `MockFacade` helper. For example, `Setting::shouldReceive('get')->andReturn(true)` before testing logic that depends on settings. Test critical paths like updates or cache invalidation in feature tests with a database transaction.
Does this package support audit logging for setting changes?
No, the package does not include audit logging. To track changes, implement a custom solution like a model observer for the settings table or use Laravel’s event system to log updates to a separate table or external service.
What are some alternatives to larapacks/setting for Laravel?
Alternatives include `spatie/laravel-settings` (more features like validation and caching), `beberlei/attributes` (for runtime configuration via attributes), or `laravel/fortify` for user-specific settings. Choose based on needs: `larapacks/setting` is lightweight, while others offer more built-in functionality.
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