{"id":25440241,"url":"https://github.com/tarfin-labs/laravel-config","last_synced_at":"2025-12-25T08:37:22.075Z","repository":{"id":40414558,"uuid":"234310353","full_name":"tarfin-labs/laravel-config","owner":"tarfin-labs","description":"Key value config management for Laravel","archived":false,"fork":false,"pushed_at":"2024-05-06T10:59:26.000Z","size":128,"stargazers_count":16,"open_issues_count":4,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-15T07:11:17.423Z","etag":null,"topics":["key-value","laravel","laravel-config","laravel-options","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarfin-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-16T11:59:35.000Z","updated_at":"2024-05-13T21:05:10.000Z","dependencies_parsed_at":"2024-04-08T13:52:49.866Z","dependency_job_id":"7a1e8837-9aed-4083-9771-c97b5e9bb573","html_url":"https://github.com/tarfin-labs/laravel-config","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Flaravel-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Flaravel-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Flaravel-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarfin-labs%2Flaravel-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarfin-labs","download_url":"https://codeload.github.com/tarfin-labs/laravel-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239281751,"owners_count":19612928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["key-value","laravel","laravel-config","laravel-options","php"],"created_at":"2025-02-17T11:30:00.790Z","updated_at":"2025-12-25T08:37:22.067Z","avatar_url":"https://github.com/tarfin-labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Laravel Config Logo](https://s3-eu-west-1.amazonaws.com/media.tarfin.com/assets/logo-config.svg)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tarfin-labs/laravel-config.svg?style=flat-square)](https://packagist.org/packages/tarfin-labs/laravel-config)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/tarfin-labs/laravel-config/tests.yml?branch=master\u0026label=tests\u0026style=flat-square)](https://github.com/tarfin-labs/laravel-config/actions/workflows/tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/tarfin-labs/laravel-config.svg?style=flat-square)](https://packagist.org/packages/tarfin-labs/laravel-config)\n\n## Introduction\n\nLaravel Config provides a database-backed configuration management system for your Laravel application. Store, retrieve, and manage configuration parameters with automatic type casting, tagging support, and nested namespaces.\n\n**Key Features:**\n- Database-backed configuration storage\n- Automatic type casting (boolean, integer, date, datetime, JSON, custom casters)\n- Tag-based organization and retrieval\n- Nested namespace support (e.g., `app.mail.host`)\n- Facade and helper function access\n- Laravel 10, 11, and 12 support\n\n## Version Compatibility\n\n### v6.x (Latest)\n\n| Requirement | Versions |\n|-------------|----------|\n| PHP | 8.1, 8.2, 8.3, 8.4, 8.5 |\n| Laravel | 10, 11, 12 |\n| PHPUnit | 10, 11, 12 |\n\n### v5.x (Maintenance)\n\n| Requirement | Versions |\n|-------------|----------|\n| PHP | 8.1, 8.2, 8.3, 8.4, 8.5 |\n| Laravel | 10, 11, 12 |\n| PHPUnit | 9.5, 10, 11, 12 |\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require tarfin-labs/laravel-config\n```\n\nPublish the configuration and migration files:\n\n```bash\nphp artisan vendor:publish --provider=\"TarfinLabs\\LaravelConfig\\LaravelConfigServiceProvider\" --tag=\"laravel-config\"\n```\n\nRun the migrations:\n\n```bash\nphp artisan migrate\n```\n\n## Quick Start\n\n```php\nuse TarfinLabs\\LaravelConfig\\Facades\\LaravelConfig;\nuse TarfinLabs\\LaravelConfig\\Config\\ConfigFactory;\nuse TarfinLabs\\LaravelConfig\\Enums\\ConfigDataType;\n\n// Create a config parameter\n$configItem = (new ConfigFactory())\n    -\u003esetName('app.debug')\n    -\u003esetType(ConfigDataType::BOOLEAN)\n    -\u003esetValue(true)\n    -\u003eget();\n\nLaravelConfig::create($configItem);\n\n// Get a config value\n$debug = LaravelConfig::get('app.debug'); // returns true (boolean)\n\n// Update a config value\nLaravelConfig::set('app.debug', false);\n\n// Check if config exists\nif (LaravelConfig::has('app.debug')) {\n    // ...\n}\n```\n\n## Usage\n\n### Using the Facade\n\n```php\nuse TarfinLabs\\LaravelConfig\\Facades\\LaravelConfig;\n\n// Get a single config value\nLaravelConfig::get('key');\nLaravelConfig::get('key', 'default'); // with default value\n\n// Set a config value\nLaravelConfig::set('key', 'value');\n\n// Check existence\nLaravelConfig::has('key');\n\n// Get all configs\nLaravelConfig::all();\n```\n\n### Creating Config Parameters\n\nUse `ConfigFactory` to build configuration items:\n\n```php\nuse TarfinLabs\\LaravelConfig\\Config\\ConfigFactory;\nuse TarfinLabs\\LaravelConfig\\Enums\\ConfigDataType;\n\n$configItem = (new ConfigFactory())\n    -\u003esetName('mail.host')\n    -\u003esetType(ConfigDataType::STRING)\n    -\u003esetValue('smtp.example.com')\n    -\u003esetDescription('SMTP server hostname')\n    -\u003esetTags(['mail', 'system'])\n    -\u003eget();\n\nLaravelConfig::create($configItem);\n```\n\n### Supported Data Types\n\nThe `ConfigDataType` enum provides the following types with automatic casting:\n\n| Type | Storage | Retrieved As |\n|------|---------|--------------|\n| `BOOLEAN` | `'1'` or `'0'` | `true` or `false` |\n| `INTEGER` | `'123'` | `123` |\n| `DATE` | `'2024-12-25'` | Carbon instance |\n| `DATE_TIME` | `'2024-12-25 14:30'` | Carbon instance |\n| `JSON` | JSON string | Array |\n\n**Custom Casters:**\n\nYou can use Laravel's custom cast classes:\n\n```php\nuse Illuminate\\Database\\Eloquent\\Casts\\AsCollection;\nuse Illuminate\\Database\\Eloquent\\Casts\\AsEnumCollection;\n\n$configItem = (new ConfigFactory())\n    -\u003esetName('allowed.statuses')\n    -\u003esetType(AsEnumCollection::class . ':' . StatusEnum::class)\n    -\u003esetValue([StatusEnum::Active, StatusEnum::Pending])\n    -\u003eget();\n```\n\n### Working with Tags\n\nOrganize configs with tags and retrieve them by tag:\n\n```php\n// Create configs with tags\n$dbHost = (new ConfigFactory())\n    -\u003esetName('db.host')\n    -\u003esetValue('localhost')\n    -\u003esetTags(['database', 'connection'])\n    -\u003eget();\n\n$dbPort = (new ConfigFactory())\n    -\u003esetName('db.port')\n    -\u003esetValue('3306')\n    -\u003esetTags(['database', 'connection'])\n    -\u003eget();\n\nLaravelConfig::create($dbHost);\nLaravelConfig::create($dbPort);\n\n// Get all configs with a specific tag\n$databaseConfigs = LaravelConfig::getByTag('database');\n\n// Get configs matching multiple tags\n$connectionConfigs = LaravelConfig::getByTag(['database', 'connection']);\n```\n\n### Nested Parameters\n\nGroup related configs using dot notation and retrieve them by namespace:\n\n```php\n// Create nested configs\nLaravelConfig::create((new ConfigFactory())-\u003esetName('mail.host')-\u003esetValue('smtp.example.com')-\u003eget());\nLaravelConfig::create((new ConfigFactory())-\u003esetName('mail.port')-\u003esetValue('587')-\u003eget());\nLaravelConfig::create((new ConfigFactory())-\u003esetName('mail.encryption')-\u003esetValue('tls')-\u003eget());\n\n// Get all configs under 'mail' namespace\n$mailConfigs = LaravelConfig::getNested('mail');\n\n// Returns a Collection with normalized names:\n// [\n//     ConfigItem { name: 'host', val: 'smtp.example.com' },\n//     ConfigItem { name: 'port', val: '587' },\n//     ConfigItem { name: 'encryption', val: 'tls' },\n// ]\n```\n\n### Updating and Deleting\n\n```php\nuse TarfinLabs\\LaravelConfig\\Config\\Config;\n\n// Update using set() for simple value changes\nLaravelConfig::set('app.name', 'New App Name');\n\n// Full update with ConfigFactory\n$config = Config::where('name', 'app.name')-\u003efirst();\n$configItem = (new ConfigFactory($config))\n    -\u003esetValue('Updated Name')\n    -\u003esetDescription('Updated description')\n    -\u003eget();\n\nLaravelConfig::update($config, $configItem);\n\n// Delete a config\n$config = Config::where('name', 'obsolete.config')-\u003efirst();\nLaravelConfig::delete($config);\n```\n\n## Helper Functions\n\nAll facade methods are available as helper functions:\n\n```php\n// Create\ncreate_config($configItem);\n\n// Read\nread_config('key');           // Get single value\nread_config();                // Get all configs\n\n// Check existence\nhas_config('key');\n\n// Update\nset_config_value('key', 'new value');  // Quick value update\nupdate_config($config, $configItem);    // Full update\n\n// Delete\ndelete_config($config);\n\n// Nested\nread_nested('mail');  // Get all configs under 'mail' namespace\n```\n\n## Database Schema\n\nThe package creates a `laravel_config` table with the following structure:\n\n| Column | Type | Description |\n|--------|------|-------------|\n| `id` | bigint | Primary key |\n| `name` | varchar (unique) | Configuration parameter name |\n| `type` | varchar | Data type (default: 'boolean') |\n| `val` | varchar (nullable) | Configuration value |\n| `description` | text (nullable) | Human-readable description |\n| `tags` | json (nullable) | Array of tags for organization |\n| `created_at` | timestamp | Creation timestamp |\n| `updated_at` | timestamp | Last update timestamp |\n\n## Configuration\n\nPublish the config file to customize the table name:\n\n```bash\nphp artisan vendor:publish --provider=\"TarfinLabs\\LaravelConfig\\LaravelConfigServiceProvider\" --tag=\"laravel-config\"\n```\n\nIn `config/laravel-config.php`:\n\n```php\nreturn [\n    'table' =\u003e env('LARAVEL_CONFIG_TABLE', 'laravel_config'),\n];\n```\n\n## Upgrading\n\n### From v5.x to v6.x\n\n**Breaking Changes:**\n\n1. **Class Renamed**: `LaravelConfig` class is now `ConfigManager`\n2. **Facade Moved**: `LaravelConfigFacade` is now `Facades\\LaravelConfig`\n3. **Version Support**: PHP 8.0 and Laravel 8-9 are no longer supported\n\n**Migration Guide:**\n\nIf you were directly instantiating the class:\n\n```php\n// Before (v5.x)\nuse TarfinLabs\\LaravelConfig\\LaravelConfig;\n$manager = new LaravelConfig();\n\n// After (v6.x)\nuse TarfinLabs\\LaravelConfig\\ConfigManager;\n$manager = new ConfigManager();\n```\n\nIf you were importing the facade directly:\n\n```php\n// Before (v5.x)\nuse TarfinLabs\\LaravelConfig\\LaravelConfigFacade;\n\n// After (v6.x)\nuse TarfinLabs\\LaravelConfig\\Facades\\LaravelConfig;\n```\n\n**No changes required if you:**\n- Use the `LaravelConfig` facade alias\n- Use helper functions (`read_config()`, `set_config_value()`, etc.)\n- Use `app('laravel-config')` container binding\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about recent changes.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Security\n\nIf you discover any security-related issues, please email development@tarfin.com instead of using the issue tracker.\n\n## Credits\n\n- [Turan Karatug](https://github.com/tkaratug)\n- [Faruk Can](https://github.com/frkcn)\n- [Yunus Emre Deligoz](https://github.com/deligoez)\n- [Hakan Ozdemir](https://github.com/hozdemir)\n- [All Contributors](../../contributors)\n\n## License\n\nLaravel Config is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarfin-labs%2Flaravel-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarfin-labs%2Flaravel-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarfin-labs%2Flaravel-config/lists"}