Laravel provides many powerful features out of the box. But when your application grows, you may need additional functionality such as role management, activity logs, media handling, backups, API filtering, and more.

This is where Spatie becomes useful.

Spatie is a company known for building open-source PHP and Laravel packages that help developers solve common development problems without implementing everything from scratch.

But there is one common question:

Which Spatie package should I use, and when should I use it?

In this guide, we will explore some of the most useful Spatie packages, their purposes, practical use cases, and installation commands.

Let’s get started!

1. User Roles and Permission Management

1. spatie/laravel-permission

Purpose: Manage roles and permissions in Laravel applications.

Imagine you are building an ERP system with different types of users:

  • Admin
  • Manager
  • Accountant
  • Sales Executive
  • Employee

Each user needs different access permissions.

Instead of building a complete role and permission system manually, you can use this package.

Installation:

composer require spatie/laravel-permission

Example:

$user->assignRole('admin');
$user->givePermissionTo('edit products');if ($user->can('edit products')) {
// Allow product editing
}

When should you use it?

  • ERP and HRM systems
  • Admin dashboards
  • Multi-role applications
  • Applications with complex authorization requirements

Documentation: https://spatie.be/docs/laravel-permission

2. Activity Logging and Auditing

2. spatie/laravel-activitylog

Purpose: Automatically record meaningful application activities.

For example, in an ERP system, you may want to know:

  • Who created an invoice?
  • Who updated a customer’s information?
  • Who changed a product price?
  • Who deleted a record?

This package helps maintain an activity history.

Installation:

composer require spatie/laravel-activitylog

Example:

activity()
->causedBy(auth()->user())
->performedOn($product)
->log('Product price updated');

You can also use the package’s LogsActivity trait to log model changes.

When should you use it?

  • Audit trails
  • Employee activity monitoring
  • ERP and accounting systems
  • Record change history
  • Administrative activity logs

Documentation: https://spatie.be/docs/laravel-activitylog

3. File and Media Management

3. spatie/laravel-medialibrary

Purpose: Associate files and media with Eloquent models.

Suppose your application has:

  • Product images
  • User profile pictures
  • Company documents
  • Blog thumbnails
  • Invoice attachments

Managing all these files manually can become complicated.

Media Library provides a structured way to associate media files with models and manage conversions.

Installation:

composer require spatie/laravel-medialibrary

Example:

$product
->addMedia($request->file('image'))
->toMediaCollection('products');

Retrieve media:

$product->getFirstMediaUrl('products');

When should you use it?

  • E-commerce applications
  • CMS and portfolio websites
  • Document management systems
  • Profile image management
  • Applications requiring image conversions

Documentation: https://spatie.be/docs/laravel-medialibrary

4. Database Backup

4. spatie/laravel-backup

Purpose: Create backups of your application files and databases.

Imagine your production server crashes or important data gets deleted. Without a reliable backup, recovering your application can be difficult.

This package helps automate database and file backups and can send notifications about backup operations.

Installation:

composer require spatie/laravel-backup

Useful command:

php artisan backup:run

When should you use it?

  • Production applications
  • ERP and accounting systems
  • E-commerce platforms
  • Applications containing important business data

Quick tip: A backup is only useful if you can restore it. Test your restore process regularly and store backups separately from your primary server.

Documentation: https://spatie.be/docs/laravel-backup

5. API Filtering and Sorting

5. spatie/laravel-query-builder

Purpose: Build API queries using request parameters.

Suppose your frontend needs to filter products by category, price, status, and sorting order.

Instead of manually writing every possible filter condition in your controller, this package provides a structured approach.

Installation:

composer require spatie/laravel-query-builder

Example:

use Spatie\QueryBuilder\QueryBuilder;
$products = QueryBuilder::for(Product::class)
->allowedFilters(['name', 'status'])
->allowedSorts(['price', 'created_at'])
->paginate(15);

Example API request:

/api/products?filter[name]=Laptop&sort=-price

When should you use it?

  • REST APIs
  • Vue.js and React applications
  • Product filtering
  • Search and sorting systems
  • Complex listing pages

Documentation: https://spatie.be/docs/laravel-query-builder

6. Data Transfer Objects (DTOs)

6. spatie/laravel-data

Purpose: Create structured data objects for transferring and validating data.

In larger applications, controllers can become difficult to maintain when they contain too much request handling, validation, and data transformation logic.

Laravel Data helps organize this logic into reusable data objects.

Installation:

composer require spatie/laravel-data

Example:

use Spatie\LaravelData\Data;
class UserData extends Data
{
public function __construct(
public string $name,
public string $email,
) {}
}

Create a data object:

$userData = UserData::from([
'name' => 'Jalis',
'email' => 'jalis@example.com',
]);

When should you use it?

  • Large Laravel applications
  • API request and response structures
  • Data transformation
  • Reusable validation and serialization
  • Applications with complex DTO requirements

Documentation: https://spatie.be/docs/laravel-data

7. Full Response Caching

7. spatie/laravel-responsecache

Purpose: Cache complete HTTP responses to improve performance.

Normally, a Laravel request may execute middleware, controllers, database queries, and view rendering before returning a response.

Response Cache can store eligible responses and serve them again for subsequent matching requests.

Installation:

composer require spatie/laravel-responsecache

When should you use it?

  • Public websites
  • Blog platforms
  • CMS websites
  • Public landing pages
  • Pages that do not change frequently

Important: Be careful when caching authenticated or personalized responses. Configure cache rules so one user’s private content is never served to another user.

Documentation: https://spatie.be/docs/laravel-responsecache

8. Multi-Tenant Applications

8. spatie/laravel-multitenancy

Purpose: Help build applications that serve multiple independent tenants.

Imagine you are developing a SaaS POS system. Different businesses use the same application, but each business should access only its own data.

For example:

  • Business A has its own customers.
  • Business B has its own products.
  • Business C has its own employees.

This package provides tools for managing tenant context and tenant-specific behavior.

Installation:

composer require spatie/laravel-multitenancy

When should you use it?

  • SaaS applications
  • Multi-company ERP systems
  • Subscription-based platforms
  • Multi-business POS applications

Important: A multitenancy package does not automatically make every query secure. You must design and test tenant isolation, authorization, database connections, and data access carefully.

Documentation: https://spatie.be/docs/laravel-multitenancy

9. Model Translation

9. spatie/laravel-translatable

Purpose: Store multiple language versions of model attributes.

Suppose you have an e-commerce website supporting English and Bangla.

A product might have:

  • English name: Mobile Phone
  • Bangla name: মোবাইল ফোন

Instead of creating separate columns for every language, this package supports translatable model attributes.

Installation:

composer require spatie/laravel-translatable

Example:

$product->setTranslations('name', [
'en' => 'Mobile Phone',
'bn' => 'মোবাইল ফোন',
]);

Retrieve a translation:

$product->getTranslation('name', 'bn');

When should you use it?

  • Multilingual websites
  • E-commerce platforms
  • CMS applications
  • International SaaS products

Documentation: https://spatie.be/docs/laravel-translatable

10. Slug Generation

10. spatie/laravel-sluggable

Purpose: Automatically generate URL-friendly slugs from model attributes.

For example:

Product Name: Laravel Developer Course
Slug: laravel-developer-course

Installation:

composer require spatie/laravel-sluggable

When should you use it?

  • Blog applications
  • Product URLs
  • CMS platforms
  • SEO-friendly URLs

Documentation: https://github.com/spatie/laravel-sluggable

11. Tagging Models

11. spatie/laravel-tags

Purpose: Attach tags to Eloquent models.

For example, a blog post might have tags such as:

  • Laravel
  • PHP
  • Programming
  • Backend Development

You can also use tags for products, articles, and other models.

Installation:

composer require spatie/laravel-tags

When should you use it?

  • Blog platforms
  • Product categorization
  • Content management systems
  • Knowledge bases

Documentation: https://spatie.be/docs/laravel-tags

12. Application Health Monitoring

12. spatie/laravel-health

Purpose: Monitor the health of a Laravel application.

A production application may depend on several services:

  • Database
  • Cache
  • Storage
  • Queue workers
  • External services

If an important service stops working, you want to know before users start reporting problems.

Installation:

composer require spatie/laravel-health

When should you use it?

  • Production applications
  • SaaS platforms
  • Applications with background workers
  • Systems requiring health checks and monitoring

Documentation: https://spatie.be/docs/laravel-health

13. PDF Generation

13. spatie/laravel-pdf

Purpose: Generate PDF documents from Laravel applications.

Examples include:

  • Invoices
  • Reports
  • Receipts
  • Business documents
  • Printable summaries

Installation:

composer require spatie/laravel-pdf

When should you use it?

  • ERP applications
  • Accounting systems
  • E-commerce invoices
  • Reporting systems

Important: Check the rendering driver and server dependencies before deploying. PDF generation may require additional software depending on the selected driver.

Documentation: https://spatie.be/docs/laravel-pdf

14. HTML to Image or PDF

14. browsershot

Purpose: Convert webpages or HTML into screenshots, images, or PDFs using a browser engine.

For example, you might want to generate:

  • Website screenshots
  • Social media preview images
  • HTML-based reports
  • Visual page previews

Installation:

composer require spatie/browsershot

When should you use it?

  • Screenshot generation
  • Automated report generation
  • HTML-to-image conversion
  • Website preview systems

Important: Browsershot requires additional server-side dependencies, including Node.js and Puppeteer/Chrome. Check the deployment environment before choosing it.

Documentation: https://spatie.be/docs/browsershot

15. Webhook Handling

15. spatie/laravel-webhook-client

Purpose: Receive incoming webhooks from external services.

For example, a payment provider may send your application a notification when a payment succeeds or fails.

Instead of building the entire webhook receiving workflow manually, this package provides a structured solution.

Installation:

composer require spatie/laravel-webhook-client

When should you use it?

  • Payment gateway integrations
  • Third-party API integrations
  • External service notifications
  • Event-driven applications

16. spatie/laravel-webhook-server

Purpose: Send webhooks from your Laravel application to external systems.

For example, when a new order is created, your application may notify another service.

Installation:

composer require spatie/laravel-webhook-server

When should you use it?

  • SaaS integrations
  • External system communication
  • Order notifications
  • Event-driven architectures

Quick tip: Webhooks should be authenticated, verified, and processed safely. Use retries and idempotency to handle duplicate deliveries.

Documentation:

17. Website Analytics

17. spatie/laravel-analytics

Purpose: Retrieve website analytics data from Google Analytics.

For example, you may want to display:

  • Website visitors
  • Page views
  • Popular pages
  • Traffic statistics

Installation:

composer require spatie/laravel-analytics

When should you use it?

  • Admin dashboards
  • Portfolio websites
  • Blog platforms
  • Marketing analytics dashboards

This package retrieves analytics data from Google Analytics; it is not a replacement for an event-tracking system inside your application.

Documentation: https://github.com/spatie/laravel-analytics

18. Sitemap Generation

18. spatie/laravel-sitemap

Purpose: Generate XML sitemaps for search engines.

A sitemap helps search engines discover the URLs on your website.

Installation:

composer require spatie/laravel-sitemap

When should you use it?

  • Blog websites
  • E-commerce websites
  • CMS applications
  • Large websites with dynamic pages

Documentation: https://spatie.be/docs/laravel-sitemap

19. Spam Protection

19. spatie/laravel-honeypot

Purpose: Help protect forms against automated spam submissions.

A honeypot adds a hidden field that legitimate users should not fill in, while some automated bots may do so.

Installation:

composer require spatie/laravel-honeypot

When should you use it?

  • Contact forms
  • Registration forms
  • Public submission forms
  • Comment systems

A honeypot is one layer of spam protection, not a complete replacement for rate limiting, validation, or other anti-abuse controls.

Documentation: https://github.com/spatie/laravel-honeypot

20. Model State Management

20. spatie/laravel-model-states

Purpose: Manage complex states and transitions in Eloquent models.

Imagine an order management system with these statuses:

  • Pending
  • Confirmed
  • Processing
  • Shipped
  • Delivered
  • Cancelled

As the application grows, managing every possible status transition through scattered conditions becomes difficult.

This package helps organize states and transitions into dedicated classes.

Installation:

composer require spatie/laravel-model-states

When should you use it?

  • Order management systems
  • Approval workflows
  • Subscription management
  • Business process applications

Documentation: https://spatie.be/docs/laravel-model-states

21. Excel and CSV Files

21. spatie/simple-excel

Purpose: Read and write Excel and CSV files with a simple API.

For example, an ERP application may need to export thousands of customer records or import product data.

Installation:

composer require spatie/simple-excel

When should you use it?

  • Data import and export
  • ERP reports
  • Customer data migration
  • Product management systems

Documentation: https://github.com/spatie/simple-excel

22. Image Optimization

22. spatie/laravel-image-optimizer

Purpose: Optimize images to reduce file sizes.

Large images can increase page loading time and consume unnecessary storage and bandwidth.

This package helps optimize images using supported image optimization tools.

Installation:

composer require spatie/laravel-image-optimizer

When should you use it?

  • E-commerce product images
  • CMS uploads
  • Blog thumbnails
  • Image-heavy applications

Important: The required optimization binaries must be available on the server.

Documentation: https://github.com/spatie/laravel-image-optimizer

23. Failed Queue Job Monitoring

23. spatie/laravel-failed-job-monitor

Purpose: Receive notifications when queued jobs fail.

Imagine your application sends emails, processes payments, or generates reports using Laravel queues.

If a job fails, you may want to know immediately instead of discovering the issue later.

Installation:

composer require spatie/laravel-failed-job-monitor

When should you use it?

  • Applications using Laravel queues
  • Email processing systems
  • Background report generation
  • Production applications

Documentation: https://github.com/spatie/laravel-failed-job-monitor

24. Schedule Monitoring

24. spatie/laravel-schedule-monitor

Purpose: Monitor scheduled tasks and detect when expected scheduled commands do not run as planned.

Laravel’s scheduler is useful for recurring tasks, but in production you also need visibility into whether those tasks are actually executing.

Installation:

composer require spatie/laravel-schedule-monitor

When should you use it?

  • Automated reports
  • Daily backups
  • Subscription renewals
  • Scheduled notifications
  • Production cron monitoring

Documentation: https://github.com/spatie/laravel-schedule-monitor

25. Dynamic Application Settings

25. spatie/laravel-settings

Purpose: Store and manage application settings using typed settings classes.

For example, an application may have configurable values such as:

  • Company name
  • Currency
  • Tax percentage
  • Invoice prefix
  • Business contact information

Instead of scattering these settings throughout your code, you can organize them into dedicated settings classes.

Installation:

composer require spatie/laravel-settings

When should you use it?

  • SaaS applications
  • ERP systems
  • Admin configuration panels
  • Applications with configurable business rules

Documentation: https://spatie.be/docs/laravel-settings

Quick Package Selection Guide

Here is a quick reference to help you choose the right package for your next Laravel project.

Your requirementPackageRoles and permissionslaravel-permissionActivity logslaravel-activitylogFile and media managementlaravel-medialibraryDatabase and file backupslaravel-backupAPI filtering and sortinglaravel-query-builderData objects and transformationlaravel-dataFull HTTP response cachinglaravel-responsecacheMulti-tenant architecturelaravel-multitenancyMultiple language attributeslaravel-translatableAutomatic URL slugslaravel-sluggableModel tagginglaravel-tagsApplication health checkslaravel-healthPDF generationlaravel-pdfWebpage screenshotsbrowsershotReceive webhookslaravel-webhook-clientSend webhookslaravel-webhook-serverGoogle Analytics integrationlaravel-analyticsXML sitemap generationlaravel-sitemapSpam protectionlaravel-honeypotModel state managementlaravel-model-statesExcel and CSV processingsimple-excelImage optimizationlaravel-image-optimizerFailed queue notificationslaravel-failed-job-monitorScheduled task monitoringlaravel-schedule-monitorApplication settingslaravel-settings

Quick Tips Before Installing Any Spatie Package

1. Do not install every package.

Install only what your application actually needs. Every additional dependency creates maintenance and compatibility considerations.

2. Check Laravel and PHP compatibility.

Before installing, check the package’s Composer requirements and supported versions.

composer show spatie/laravel-permission --all

3. Read the official documentation.

Packages can have different installation, configuration, migration, and deployment requirements.

4. Test packages before production deployment.

Test permissions, file handling, backups, caching, and integrations in a development or staging environment.

5. Understand Laravel’s built-in features first.

Laravel already provides authentication building blocks, authorization policies, queues, caching, validation, notifications, and more.

A third-party package should solve a real problem or improve maintainability — not simply add another dependency.