The Cherry Picker package now provides global helper functions (config(), data_get(), env()) similar to Laravel's helpers but working standalone with the PHP DI container.
File: src/helpers.php
Three helper functions are provided:
// Get a config value using dot notation
config('cherry-picker.git.username') // Returns: 'your.username'
config('cherry-picker.gitlab.api_url') // Returns: API URL
// Get all config
config() // Returns: entire config array
// Get environment variable
env('GIT_USERNAME') // Returns: env var value
env('MISSING_VAR', 'default') // Returns: default if not found
data_get('array.in.some.value') // get data from array safelyThe helpers are automatically loaded via composer's files autoload configuration:
"autoload": {
"psr-4": {"Mu\\CherryPicker\\": "src"},
"files": ["src/helpers.php"]
}This means helpers are available everywhere after composer install.
When you run the CLI or use the container:
- Container is created with base path
- ConfigLoader.initialize() is called:
- Loads
.envfile using vlucas/phpdotenv - Loads all config files from
src/config/
- Loads
- Config is singleton
To add new configuration:
- Add to
.env:
MY_NEW_VAR=value- Add to
src/config/cherry-picker.php:
return [
'my_section' => [
'my_key' => env('MY_NEW_VAR', 'default'),
],
// ... other config
];- Use in code:
$value = config('cherry-picker.my_section.my_key');