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

Laravel Sdk Laravel Package

getkeymanager/laravel-sdk

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require getkeymanager/laravel-sdk
    

    The package auto-discovers the service provider (no manual registration needed).

  2. Publish Configuration

    php artisan vendor:publish --provider="KeyManager\LaravelSdk\KeyManagerServiceProvider" --tag="config"
    

    Edit config/keymanager.php with your API key and environment settings.

  3. First Validation Check

    use KeyManager\Facades\KeyManager;
    
    if (!KeyManager::validate()) {
        abort(403, 'License validation failed');
    }
    
  4. Middleware Protection Add to app/Http/Kernel.php:

    'web' => [
        \KeyManager\LaravelSdk\Http\Middleware\ValidateLicense::class,
        // ...
    ],
    

First Use Case: Route Protection

Protect a route with license validation:

Route::middleware(['web', 'validate.license'])->group(function () {
    Route::get('/premium', [PremiumController::class, 'index']);
});

Implementation Patterns

Core Workflows

1. License Validation

  • Basic Check
    if (KeyManager::validate()) {
        // Valid license
    }
    
  • Offline-First Validation (v3.0+)
    KeyManager::validate(['offline' => true]); // Uses cached license
    

2. Feature Flags

  • Middleware-Based
    Route::middleware(['feature:analytics'])->group(...);
    
  • Programmatic Check
    if (KeyManager::featureEnabled('analytics')) {
        // Enable feature
    }
    

3. License Activation

  • CLI Activation
    php artisan keymanager:activate --license=YOUR_LICENSE_KEY
    
  • Programmatic Activation
    KeyManager::activate('YOUR_LICENSE_KEY');
    

4. Configuration Inheritance

Leverage environment-specific configs:

// config/keymanager.php
'environments' => [
    'local' => [
        'api_key' => env('KEYMANAGER_LOCAL_API_KEY'),
    ],
    'production' => [
        'api_key' => env('KEYMANAGER_API_KEY'),
    ],
],

Integration Tips

Middleware Chaining

Combine with Laravel’s built-in middleware:

Route::middleware(['auth', 'validate.license', 'throttle:60'])->group(...);

Logging Integration

Enable logging in config/keymanager.php:

'logging' => true,

Logs appear in storage/logs/keymanager.log.

Session Caching

Automatically caches license validation results per session. Disable with:

KeyManager::validate(['cache' => false]);

Artisan Commands

  • Check License Status
    php artisan keymanager:status
    
  • Deactivate License
    php artisan keymanager:deactivate
    

Gotchas and Tips

Pitfalls

  1. Offline Validation Quirks

    • Offline mode (offline: true) relies on cached data. Ensure cache:config is enabled.
    • Fix: Run php artisan cache:clear if offline checks fail unexpectedly.
  2. Middleware Caching

    • The validate.license middleware caches validation results. Override with:
      KeyManager::validate(['cache' => false]);
      
  3. Environment Mismatch

    • If using environments config, ensure APP_ENV matches your config keys.
    • Debug: Check config('keymanager.environment') in Tinker.
  4. Rate Limiting

    • The SDK respects Laravel’s rate-limiting middleware. Add throttle if needed:
      Route::middleware(['throttle:60,1'])->group(...);
      

Debugging

  • Enable Verbose Logging

    KeyManager::setLogLevel(\Monolog\Logger::DEBUG);
    
  • Check License Response

    $response = KeyManager::validate(['debug' => true]);
    dd($response->getOriginalContent());
    
  • Validate API Key Test connectivity with:

    php artisan keymanager:status --verbose
    

Extension Points

  1. Custom Validation Logic Extend the validator:

    KeyManager::extendValidator(function ($license) {
        return $license['custom_field'] === 'expected_value';
    });
    
  2. Event Listeners Listen for license events:

    KeyManager::listen('license.validated', function ($license) {
        // Custom logic
    });
    
  3. Override Middleware Publish and modify the middleware:

    php artisan vendor:publish --tag="keymanager.middleware"
    

    Edit app/Http/Middleware/ValidateLicense.php.

  4. Custom Artisan Commands Extend the SDK’s commands:

    KeyManager::extendCommand('keymanager:custom', function () {
        // Custom logic
    });
    
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui