Skip to content

Vendor-neutral, engineer-written explanations. Clear definitions first, then practical steps with real examples — no fluff.

How do I install and use a Laravel package?

SB
Written by StageBit Engineering Team
Updated January 2026 2 min readVerified by engineers

Laravel packages allow you to extend application functionality efficiently. From authentication and admin panels to search tools, AI integrations, and more, packages save development time and reduce complexity.

1. Install via Composer

Use Composer, Laravel’s dependency manager, to install a package:

composer require vendor/package-name

Pro-tip: You can specify a version constraint to ensure compatibility:

composer require vendor/package-name:^1.0.4

If the package is for development tools only (like Debugbar or Pest), use:

composer require vendor/package-name --dev

Note: Running composer require automatically updates composer.json and composer.lock.

2. Service Provider Registration / Auto-Discovery

Modern Laravel packages support auto-discovery, so most of the time you don’t need manual registration. If a package requires manual registration:

// Add this provider to bootstrap/providers.php array in Laravel 11/12
Vendor\Package\ServiceProvider::class,

This replaces the older practice of manually editing config/app.php in Laravel 5.x.

3. Publish Configuration & Assets

Many packages include configuration files, migrations, or assets. Publish only what you need:

# Publish config files (streamlined for Laravel v11/v12)
php artisan config:publish vendor/package-name

# Or use vendor:publish with tags
php artisan vendor:publish --tag=package-name-config
php artisan vendor:publish --tag=package-name-migrations

Pro-tip: Using --tag prevents unnecessary clutter in your project.

4. Run Migrations (if applicable)

If the package adds database tables, run:

php artisan migrate

5. Implementing the Package

Integrate the package functionality using Dependency Injection or Facades for maintainable and testable code.

Dependency Injection Example

use Vendor\Package\SomeClass;

public function index(SomeClass $package) {
    $package->performAction();
}

Facade Example

use Vendor\Package\Facades\PackageName;

public function store() {
    PackageName::doSomething();
}

6. Updating & Removing Packages

  • Update all packages: composer update
  • Remove a package: composer remove vendor/package-name

7. Documentation & Research

  • Always read the package’s official documentation for advanced usage, options, and compatibility.
  • Choose packages with active community support to ensure reliability.

8. Pro-Tips for Laravel 11/12

  • Use version constraints to prevent breaking changes.
  • Leverage auto-discovery to simplify service provider management.
  • Publish only necessary configuration or migrations using tags.
  • Implement functionality with Dependency Injection wherever possible for easier testing.
  • Engage with the package community for updates, bug fixes, and improvements.

Summary

  • Install packages via Composer (--dev for dev tools)
  • Auto-discovery handles most service providers; manual registration in bootstrap/providers.php if required
  • Publish only required files with --tag or config:publish
  • Run migrations when needed
  • Integrate using Dependency Injection or Facades
  • Keep packages updated and monitor version compatibility
  • Read documentation and engage with the package community

By following these modern Laravel 11/12 practices, you can efficiently leverage packages while keeping your application maintainable, testable, and up-to-date.

Was this answer helpful?

Your feedback helps us improve our answers.

Still need help?

Talk to our Laravel experts

We've handled GDPR/CCPA compliance for dozens of EU & US Laravel.

Talk to Laravel Experts

Tell us more about your brand!

Rohit Kundale, Our VP of Sales and Marketing is ready to meet with your team.