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 Seo Booster Laravel Package

sajadsdi/laravel-seo-booster

Laravel package to help boost your site’s SEO by managing common on-page metadata like titles, descriptions and social tags. Designed to integrate into Laravel apps to improve search visibility and sharing previews with minimal setup.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require sajadsdi/laravel-seo-booster
    

    Publish the package configuration (if applicable):

    php artisan vendor:publish --provider="Sajadsdi\SeoBooster\SeoBoosterServiceProvider"
    
  2. First Use Case:

    • SEO Meta Tags: Dynamically generate SEO meta tags for routes or views.
      use Sajadsdi\SeoBooster\Facades\SeoBooster;
      
      // In a controller or blade template
      SeoBooster::setTitle('Page Title');
      SeoBooster::setDescription('Page description for SEO');
      SeoBooster::setKeywords(['keyword1', 'keyword2']);
      SeoBooster::setCanonicalUrl(url()->current());
      
    • Sitemap Generation: Generate a sitemap.xml for your site.
      php artisan seo:sitemap
      
  3. Where to Look First:

    • Documentation: Check the package’s README.md for basic setup (if available).
    • Service Provider: Inspect Sajadsdi\SeoBooster\SeoBoosterServiceProvider for bindings and boot logic.
    • Facade: Use SeoBooster facade for quick meta tag management.
    • Artisan Commands: List available commands:
      php artisan list
      

Implementation Patterns

Usage Patterns

  1. Dynamic Meta Tags:

    • Route-Based SEO: Use middleware to set SEO tags per route.
      // app/Http/Middleware/SetSeoTags.php
      public function handle(Request $request, Closure $next) {
          SeoBooster::setTitle(config("seo.routes.{$request->route()->getName()}.title"));
          return $next($request);
      }
      
    • View-Based SEO: Override SEO tags in Blade templates.
      @inject('seo', 'Sajadsdi\SeoBooster\Facades\SeoBooster')
      <title>{{ $seo->getTitle() }}</title>
      <meta name="description" content="{{ $seo->getDescription() }}">
      
  2. Sitemap Management:

    • Customize Sitemap: Extend the default sitemap logic by publishing and modifying the config.
      // config/seo.php
      'sitemap' => [
          'priority' => 0.8,
          'changefreq' => 'daily',
          'routes' => [
              'home' => '/',
              'about' => '/about',
          ],
      ],
      
    • Generate Sitemap:
      php artisan seo:sitemap
      
    • Automate Sitemap: Schedule the sitemap generation via Laravel’s scheduler.
      // app/Console/Kernel.php
      protected function schedule(Schedule $schedule) {
          $schedule->command('seo:sitemap')->daily();
      }
      
  3. Open Graph (OG) and Twitter Cards:

    • Set OG/Twitter meta tags dynamically.
      SeoBooster::setOgTitle('Open Graph Title');
      SeoBooster::setOgDescription('Open Graph Description');
      SeoBooster::setOgImage(url('images/og-image.jpg'));
      SeoBooster::setTwitterCard('summary_large_image');
      
  4. SEO Analytics:

    • Integrate with Google Analytics or other tools by extending the package’s event system (if supported).

Workflows

  1. Development Workflow:

    • Local Testing: Use php artisan seo:debug (if available) to inspect current SEO settings.
    • CI/CD Integration: Add sitemap generation to your deployment pipeline.
      # .github/workflows/deploy.yml
      - name: Generate Sitemap
        run: php artisan seo:sitemap
      
  2. Content Management:

    • CMS Integration: Sync SEO fields from a CMS (e.g., Laravel Nova, Filament) to the package’s config or database.
    • Database Storage: Store SEO metadata in a database table and fetch it dynamically.
      $seoData = SeoModel::where('slug', $slug)->first();
      SeoBooster::setTitle($seoData->title);
      
  3. Multi-Language SEO:

    • Use Laravel’s localization features to set language-specific SEO tags.
      $locale = app()->getLocale();
      SeoBooster::setTitle(__("seo.{$locale}.title"));
      

Integration Tips

  1. Middleware Integration:

    • Apply SEO middleware globally or per route group.
      Route::middleware(['set.seo.tags'])->group(function () {
          // Routes with SEO tags
      });
      
  2. Blade Directives:

    • Create custom Blade directives for SEO tags.
      // app/Providers/BladeServiceProvider.php
      Blade::directive('seo', function ($expression) {
          return "<?php echo Sajadsdi\SeoBooster\Facades\SeoBooster::{$expression}(); ?>";
      });
      
      Usage:
      <title>@seo('getTitle')</title>
      
  3. Testing:

    • Test SEO tags in feature tests.
      public function test_seo_tags_are_set() {
          $response = $this->get('/');
          $response->assertSee('<title>Page Title</title>');
          $response->assertSee('<meta name="description" content="Page description for SEO">');
      }
      
  4. Performance Optimization:

    • Cache SEO metadata for static pages.
      $seoCacheKey = "seo:{$slug}";
      $seoData = Cache::remember($seoCacheKey, now()->addHours(1), function () use ($slug) {
          return SeoModel::where('slug', $slug)->first();
      });
      SeoBooster::hydrate($seoData);
      

Gotchas and Tips

Pitfalls

  1. Configuration Overrides:

    • Issue: Package config may override Laravel’s default settings unintentionally.
    • Fix: Always publish and review the config file after installation.
      php artisan vendor:publish --provider="Sajadsdi\SeoBooster\SeoBoosterServiceProvider" --tag=config
      
  2. Middleware Conflicts:

    • Issue: SEO middleware might conflict with other middleware (e.g., modifying $request globally).
    • Fix: Test middleware in isolation and avoid modifying $request unless necessary.
  3. Sitemap Generation:

    • Issue: Sitemap might include routes that shouldn’t be indexed (e.g., admin routes).
    • Fix: Exclude routes in the config:
      'sitemap' => [
          'exclude' => [
              'admin.*',
              'login',
          ],
      ],
      
  4. Database Dependencies:

    • Issue: The package might assume a specific database schema for SEO storage.
    • Fix: Check for migrations or seeders and adapt them to your schema.
  5. Caching Issues:

    • Issue: SEO tags might not update immediately due to caching.
    • Fix: Clear relevant caches after updating SEO data:
      php artisan cache:clear
      php artisan view:clear
      
  6. Facade vs. Direct Usage:

    • Issue: Using the facade directly might lead to unexpected behavior in testing or production.
    • Fix: Prefer dependency injection where possible:
      public function __construct(private SeoBooster $seoBooster) {}
      

Debugging

  1. SEO Debugging:

    • Tool: Use browser dev tools to inspect meta tags and ensure they render correctly.
    • Artisan Command: If available, use php artisan seo:debug to log current SEO settings.
  2. Sitemap Debugging:

    • Check Output: Inspect the generated sitemap.xml for correctness.
    • Validate: Use Google’s Sitemap Tester to validate the sitemap.
  3. Logging:

    • Enable Laravel logging to debug package behavior:
      // config/logging.php
      'channels' => [
          'seo' => [
              'driver' => 'single',
              'path' => storage_path('logs/seo.log'),
              'level' => 'debug',
          ],
      ],
      
    • Log SEO-related events:
      \Log::debug('SEO Tags', [
          'title' => SeoBooster::getTitle(),
          'description' => SeoBooster::getDescription(),
      ]);
      

Config Quirks

  1. Missing Config:

    • Issue: The package might not publish its config file by default.
    • Fix: Manually publish the config:
      php artisan vendor:publish --provider="Sajadsdi\SeoBooster\SeoBoosterServiceProvider" --tag=config
      
  2. **

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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime