j0k3r/graby-site-config
Configuration repository for Graby, providing per-site extraction rules to improve readable content parsing. Includes curated site-specific settings (XPath/filters/cleanup) to enhance article detection and text quality across many domains.
Installation
composer require j0k3r/graby-site-config
Add to config/app.php under providers:
J0k3r\GrabySiteConfig\GrabySiteConfigServiceProvider::class,
Publish Config
php artisan vendor:publish --provider="J0k3r\GrabySiteConfig\GrabySiteConfigServiceProvider" --tag="config"
This generates a graby-site-config.php in config/.
First Use Case: Fetching Config
use J0k3r\GrabySiteConfig\Facades\GrabySiteConfig;
$config = GrabySiteConfig::get('key'); // Returns cached or fetched config
graby-site-config.php).GrabySiteConfig::clearCache(); // Clear all cached configs
GrabySiteConfig::clearCache('specific_key'); // Clear a single key
GrabySiteConfig::setSource('https://api.example.com/config.json');
$config = GrabySiteConfig::get('feature_flags');
$value = GrabySiteConfig::get('analytics_id', 'default_analytics_id');
env() to switch sources per environment:
$source = env('CONFIG_SOURCE', 'local');
GrabySiteConfig::setSource($source);
<div data-config="{{ GrabySiteConfig::get('theme_color') }}"></div>
GrabySiteConfig::listen('feature_flags', function ($newConfig) {
Log::info('Feature flags updated:', $newConfig);
});
graby-site-config.php for cache_ttl.sync() for critical updates:
GrabySiteConfig::sync('key', $value); // Atomic write
GrabySiteConfig::setDebug(true); // Logs fetch/parse errors
GrabySiteConfig::getRawSource() to inspect raw responses for debugging.J0k3r\GrabySiteConfig\Contracts\ConfigSource for non-HTTP sources (e.g., database):
class DatabaseSource implements ConfigSource {
public function fetch(): array { ... }
}
Register via:
GrabySiteConfig::extend('db', function () {
return new DatabaseSource();
});
GrabySiteConfig::preload(['key1', 'key2']);
cache_ttl = 0 in graby-site-config.php for local development.env() or Vault for sensitive values.$config = json_decode(GrabySiteConfig::getRawSource(), true, 512, JSON_THROW_ON_ERROR);
How can I help you explore Laravel packages today?