jooservices / laravel-config
Store and retrieve application configuration in database (MongoDB) with caching.
Requires
- php: ^8.5
- illuminate/cache: ^11.0|^12.0
- illuminate/config: ^11.0|^12.0
- illuminate/database: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- mongodb/laravel-mongodb: ^4.0|^5.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0|^10.0
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.0
- dev-develop
- v1.1.0
- 1.0.0
- dev-dependabot/github_actions/softprops/action-gh-release-3
- dev-dependabot/github_actions/ossf/scorecard-action-2.4.3
- dev-dependabot/github_actions/actions/upload-artifact-7
- dev-dependabot/github_actions/codecov/codecov-action-6
- dev-dependabot/github_actions/github/codeql-action-4.35.4
- dev-dependabot/github_actions/actions/checkout-6
- dev-dependabot/github_actions/ramsey/composer-install-4
- dev-chore/governance-alignment-20260512
- dev-chore/sync-dto-cicd-ruleset-20260512
- dev-chore/sync-dto-standards-20260512
- dev-master
- dev-release/1.1.0
- dev-feature/sync-dto-standards-and-config-improvements
This package is auto-updated.
Last update: 2026-05-12 07:39:17 UTC
README
The JOOservices Laravel Config package stores Laravel application configuration in MongoDB and exposes typed runtime access through JOOservices\\LaravelConfig\\Facades\\Config.
Package name: jooservices/laravel-config
Install
composer require jooservices/laravel-config
Publish configuration:
php artisan vendor:publish --tag=config-store-config
Requirements
- PHP 8.5+
- Laravel 11 or 12
- MongoDB via
mongodb/laravel-mongodb - MongoDB PHP extension
What the package does
- stores values as
group,key,value, andtypedocuments in MongoDB - loads a full in-memory map on first read and optionally caches that map
- supports typed normalization for
string,int,float,bool,array,json, andnull - provides runtime
get,set,forget,group,all,refresh, andfreshoperations - ships Artisan commands for common operator tasks
Quick example
use JOOservices\LaravelConfig\Facades\Config; Config::set('system.site_name', 'XCrawler'); Config::set('system.enabled', true); Config::set('payment.retry_times', 3); $siteName = Config::get('system.site_name'); $system = Config::group('system'); $fresh = Config::fresh('system.site_name');
Path format and validation
Paths must use the group.key format.
Rejected values include:
- empty paths
- missing dots
- leading dots
- trailing dots
- double dots
- empty group or empty key segments
Examples:
- valid:
system.site_name - valid:
payment.retry_times - invalid:
system - invalid:
.system.site_name - invalid:
system. - invalid:
system..site_name
Cache and memory behavior
get,has,group, andallload from memory first- when memory is cold, the service reads the cached full map first, then MongoDB on cache miss
setandforgetupdate MongoDB and keep the cache coherent without overwriting unrelated keysrefreshclears in-memory state and the configured cache key, then reloads from MongoDBfreshbypasses the in-memory map and cache for a direct MongoDB read
Important limitation:
- the in-memory map is process-local, so long-running workers, Horizon processes, Octane workers, or multiple PHP-FPM workers can hold stale state until
refresh()is called or the process is recycled
MongoDB index requirement
Create a unique compound index on group and key so each config path remains unique.
php artisan config-store:ensure-index
Equivalent Mongo shell command:
db.configs.createIndex( { group: 1, key: 1 }, { name: 'config_group_key_unique', unique: true } );
Artisan commands
php artisan config-store:get system.site_name --default="Default" php artisan config-store:set system.site_name XCrawler php artisan config-store:set system.enabled true --type=bool php artisan config-store:forget system.site_name php artisan config-store:refresh php artisan config-store:ensure-index
Security note
This package can store sensitive values, but it does not encrypt stored values by default. Do not place credentials or secrets in this store unless your MongoDB deployment, backups, and access controls already satisfy your security requirements.
Upgrade note
The canonical namespace for this package is now JOOservices\\LaravelConfig\\. Existing code that imports JooServices\\LaravelConfig\\... must be updated. This repository does not currently ship a compatibility alias layer.
Documentation
Start with:
- Documentation Hub
- Installation
- Quick Start
- Configuration
- Usage Guide
- Release Process
- Risks, Legacy, and Gaps
- Changelog
AI support
This repository includes AI contributor guidance and skill files.
Start with:
Development
composer lint
composer lint:all
composer test
composer test:coverage
composer check
composer ci
MongoDB must be available for integration tests.