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

Filament Developer Gate Laravel Package

tomatophp/filament-developer-gate

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require tomatophp/filament-developer-gate
    

    Publish the config file (if needed):

    php artisan vendor:publish --tag="filament-developer-gate-config"
    
  2. Register Middleware: Add the middleware to your app/Http/Kernel.php under $routeMiddleware:

    'developer.gate' => \TomatoPHP\FilamentDeveloperGate\Http\Middleware\DeveloperGateMiddleware::class,
    
  3. First Use Case: Protect a route (e.g., a Filament admin panel route) in routes/web.php:

    Route::get('/admin', function () {
        return view('filament.app');
    })->middleware(['auth:sanctum', 'developer.gate']);
    
  4. Configure Password: Set the password in .env:

    DEVELOPER_GATE_PASSWORD=your_secure_password_here
    

    Or override in config/filament-developer-gate.php.


Implementation Patterns

Workflows

  1. Protecting Filament Routes: Apply the middleware to Filament’s admin routes:

    Route::group([
        'middleware' => ['auth:sanctum', 'developer.gate'],
        'prefix' => 'admin',
    ], function () {
        Filament::serving(function () {
            // Filament setup
        });
    });
    
  2. Dynamic Password Management: Use a config file to manage passwords across environments:

    // config/filament-developer-gate.php
    'password' => env('DEVELOPER_GATE_PASSWORD'),
    'whitelist' => ['127.0.0.1', '192.168.*.*'], // Optional IP whitelisting
    
  3. Integration with Filament Panels: Extend the middleware to validate Filament’s built-in auth:

    // app/Providers/Filament/AdminPanelProvider.php
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->middleware([
                \TomatoPHP\FilamentDeveloperGate\Http\Middleware\DeveloperGateMiddleware::class,
            ]);
    }
    
  4. Custom Login Blade: Override the default login view by publishing assets:

    php artisan vendor:publish --tag="filament-developer-gate-views"
    

    Then modify resources/views/vendor/filament-developer-gate/login.blade.php.


Gotchas and Tips

Pitfalls

  1. Password Exposure:

    • Avoid hardcoding passwords in config/filament-developer-gate.php. Always use .env.
    • Rotate passwords frequently, especially in shared environments.
  2. Middleware Order:

    • Place developer.gate after auth:sanctum or auth:session to avoid bypassing Filament’s auth entirely.
    • Example:
      ->middleware(['auth:sanctum', 'developer.gate']) // Correct
      ->middleware(['developer.gate', 'auth:sanctum']) // Incorrect (may fail)
      
  3. Caching Issues:

    • Clear route cache if changes to middleware aren’t reflected:
      php artisan route:clear
      
  4. IP Whitelisting:

    • If using whitelist, ensure your local IP is included. Test with:
      'whitelist' => ['127.0.0.1', '::1', '192.168.1.*'],
      

Debugging

  1. Login Failures:

    • Check .env for correct DEVELOPER_GATE_PASSWORD.
    • Verify the middleware is registered in Kernel.php.
  2. Blade Overrides:

    • If custom views aren’t loading, ensure the publish step was run and the view path is correct.
  3. Logs:

    • Enable debug mode in config/filament-developer-gate.php:
      'debug' => env('APP_DEBUG', false),
      
    • Check Laravel logs (storage/logs/laravel.log) for middleware errors.

Extension Points

  1. Custom Validation: Extend the middleware to add logic (e.g., time-based access):

    // app/Http/Middleware/ExtendedDeveloperGate.php
    public function handle($request, Closure $next)
    {
        if (!$this->isDeveloper($request)) {
            return redirect()->route('developer.gate.login');
        }
        return $next($request);
    }
    
  2. Multi-Factor Integration: Combine with Laravel Fortify for 2FA:

    ->middleware(['auth:sanctum', 'verified', 'developer.gate'])
    
  3. Environment-Specific Rules: Use config overrides for different environments (e.g., disable in production):

    // config/filament-developer-gate.php
    'enabled' => !app()->environment('production'),
    
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours