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

Graby Site Config Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require j0k3r/graby-site-config
    

    Add to config/app.php under providers:

    J0k3r\GrabySiteConfig\GrabySiteConfigServiceProvider::class,
    
  2. Publish Config

    php artisan vendor:publish --provider="J0k3r\GrabySiteConfig\GrabySiteConfigServiceProvider" --tag="config"
    

    This generates a graby-site-config.php in config/.

  3. First Use Case: Fetching Config

    use J0k3r\GrabySiteConfig\Facades\GrabySiteConfig;
    
    $config = GrabySiteConfig::get('key'); // Returns cached or fetched config
    

Implementation Patterns

1. Caching Strategy

  • Automatic Caching: The package caches fetched configs by default (TTL configurable in graby-site-config.php).
  • Manual Cache Invalidation:
    GrabySiteConfig::clearCache(); // Clear all cached configs
    GrabySiteConfig::clearCache('specific_key'); // Clear a single key
    

2. Remote Config Integration

  • Dynamic Updates: Fetch configs from remote sources (e.g., JSON endpoints, S3, or CDN) without redeploying:
    GrabySiteConfig::setSource('https://api.example.com/config.json');
    $config = GrabySiteConfig::get('feature_flags');
    

3. Fallback Values

  • Provide defaults if remote config fails:
    $value = GrabySiteConfig::get('analytics_id', 'default_analytics_id');
    

4. Environment-Specific Configs

  • Use env() to switch sources per environment:
    $source = env('CONFIG_SOURCE', 'local');
    GrabySiteConfig::setSource($source);
    

5. Laravel Blade Integration

  • Access configs directly in views:
    <div data-config="{{ GrabySiteConfig::get('theme_color') }}"></div>
    

6. Event Listeners for Updates

  • Listen for config changes (e.g., via webhooks):
    GrabySiteConfig::listen('feature_flags', function ($newConfig) {
        Log::info('Feature flags updated:', $newConfig);
    });
    

Gotchas and Tips

Pitfalls

  • Cache Staleness: If TTL is too long, configs may not update in time. Monitor graby-site-config.php for cache_ttl.
  • Source Validation: Always validate remote sources (e.g., HTTPS, CORS) to avoid security risks.
  • Race Conditions: Concurrent writes to the same config key may cause inconsistencies. Use sync() for critical updates:
    GrabySiteConfig::sync('key', $value); // Atomic write
    

Debugging

  • Enable Logging:
    GrabySiteConfig::setDebug(true); // Logs fetch/parse errors
    
  • Check HTTP Errors: Use GrabySiteConfig::getRawSource() to inspect raw responses for debugging.

Extension Points

  • Custom Sources: Extend 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();
    });
    

Performance Tips

  • Preload Configs: Fetch all needed configs in a single request during boot:
    GrabySiteConfig::preload(['key1', 'key2']);
    
  • Disable Caching for Dev: Set cache_ttl = 0 in graby-site-config.php for local development.

Security

  • Sensitive Data: Avoid storing secrets in remote configs. Use Laravel’s env() or Vault for sensitive values.
  • Input Sanitization: Validate remote JSON responses to prevent injection:
    $config = json_decode(GrabySiteConfig::getRawSource(), true, 512, JSON_THROW_ON_ERROR);
    
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky