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 Coming Soon Laravel Package

tauseedzaman/laravel-coming-soon

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require tauseedzaman/laravel-coming-soon
    php artisan vendor:publish --tag=coming-soon-config
    php artisan migrate
    
    • Focus on config/coming-soon.php for core settings (e.g., enabled, title, description, launch_date).
  2. First Use Case:

    • Enable the coming-soon mode in config/coming-soon.php:
      'enabled' => true,
      'launch_date' => '2024-12-31', // Format: Y-m-d
      
    • Test by visiting any route—your site should now show the coming-soon page.
  3. Quick Customization:

    • Override the default view by publishing the blade template:
      php artisan vendor:publish --tag=coming-soon-views
      
    • Edit resources/views/vendor/coming-soon/index.blade.php.

Implementation Patterns

Core Workflows

  1. Dynamic Launch Date Handling:

    • Use the ComingSoon facade or service container to check if the coming-soon mode is active:
      use Tauseedzaman\ComingSoon\Facades\ComingSoon;
      
      if (ComingSoon::isActive()) {
          // Show coming-soon page or redirect
      }
      
    • Programmatically enable/disable via config or a controller:
      ComingSoon::enable(); // or disable()
      
  2. Route Protection:

    • Protect specific routes by adding the middleware to RouteServiceProvider:
      protected function mapWebRoutes()
      {
          $this->router->middleware(['coming.soon'])->group(function () {
              // Routes to protect
          });
      }
      
    • Exclude routes (e.g., admin or API) by prefixing them with auth: or custom middleware.
  3. Countdown Logic:

    • Access the remaining days in Blade:
      @php
          $daysLeft = \Tauseedzaman\ComingSoon\Facades\ComingSoon::daysLeft();
      @endphp
      <p>Launching in {{ $daysLeft }} days!</p>
      
    • Use in JavaScript for dynamic updates:
      const daysLeft = @json($daysLeft);
      // Update UI with setInterval()
      
  4. Email/SMS Notifications (Advanced):

    • Extend the package by listening to the coming-soon.launch event (if supported) or manually trigger notifications when the launch date is reached:
      if (ComingSoon::isLaunchDay()) {
          Notification::route('mail', 'user@example.com')
                      ->notify(new LaunchNotification());
      }
      

Integration Tips

  • Laravel Mix/Vite: Dynamically inject the countdown into your frontend by exposing $daysLeft via a Laravel Mix helper or Vite plugin.
  • Localization: Override the default language strings by publishing the language files:
    php artisan vendor:publish --tag=coming-soon-lang
    
    Then edit resources/lang/en/coming-soon.php.
  • SEO: Use middleware to set HTTP headers (e.g., X-Robots-Tag: noindex) when coming-soon mode is active:
    public function handle($request, Closure $next)
    {
        if (ComingSoon::isActive()) {
            $request->headers->set('X-Robots-Tag', 'noindex, nofollow');
        }
        return $next($request);
    }
    

Gotchas and Tips

Pitfalls

  1. Middleware Order:

    • Ensure the coming.soon middleware runs before other middleware (e.g., auth, guest) to avoid conflicts. Add it to $middlewarePriority in App\Http\Kernel.php:
      protected $middlewarePriority = [
          \Tauseedzaman\ComingSoon\Http\Middleware\ComingSoonMiddleware::class,
          // Other middleware...
      ];
      
  2. Database Migration:

    • The package creates a coming_soon_settings table. If you customize the migration, do not delete the original table—it’s required for the package to function. Instead, extend it:
      php artisan vendor:publish --tag=coming-soon-migrations
      
      Then modify database/migrations/xxxx_create_coming_soon_settings_table.php.
  3. Launch Date Format:

    • The launch_date in config/coming-soon.php must be in Y-m-d format. Invalid dates will silently disable the countdown logic.
  4. Caching:

    • If using Laravel’s cache, clear it after changing the launch_date or enabled config:
      php artisan cache:clear
      
    • The package may cache the coming-soon status; check for ComingSoon::cache() methods or config options.
  5. Route Caching:

    • After enabling/disabling the coming-soon mode, regenerate routes:
      php artisan route:clear
      

Debugging

  • Check Active Status:
    • Verify the coming-soon mode is active by logging:
      \Log::info('Coming Soon Active:', ['status' => ComingSoon::isActive()]);
      
  • View Configuration:
    • Dump the config to ensure settings are loaded:
      \Log::info('Coming Soon Config:', config('coming-soon'));
      
  • Middleware Debugging:
    • Temporarily disable the middleware to isolate issues:
      // In App\Http\Kernel.php
      protected $middleware = [
          // Comment out: \Tauseedzaman\ComingSoon\Http\Middleware\ComingSoonMiddleware::class,
      ];
      

Extension Points

  1. Custom Logic:

    • Override the ComingSoonServiceProvider by publishing and extending it:
      php artisan vendor:publish --tag=coming-soon-provider
      
    • Add custom logic to register() or boot() methods in app/Providers/ComingSoonServiceProvider.php.
  2. API Endpoints:

    • Create a custom API endpoint to toggle coming-soon mode:
      Route::post('/admin/coming-soon', function () {
          $enabled = request()->boolean('enabled');
          config(['coming-soon.enabled' => $enabled]);
          return response()->json(['status' => 'success']);
      });
      
  3. Frontend Customization:

    • Extend the Blade template to include additional fields (e.g., newsletter signup):
      @extends('vendor.coming-soon.index')
      @section('extra_content')
          <form action="/subscribe" method="POST">
              <!-- Newsletter form -->
          </form>
      @endsection
      
  4. Multi-Tenant Support:

    • Store coming-soon settings per tenant by extending the coming_soon_settings table with a tenant_id column and querying accordingly:
      use Tauseedzaman\ComingSoon\Models\ComingSoonSetting;
      
      $settings = ComingSoonSetting::where('tenant_id', auth()->tenant()->id)->first();
      
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.
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
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