How7o
  • Home
  • Marketing
    MarketingShow More
    The Beginner’s Guide about Facebook Advertising
    6 Min Read
    64 Creative Marketing Ideas to Boost Your Business
    6 Min Read
  • OS
    OSShow More
    How to force quit frozen apps in Ubuntu
    Force Close an App in Ubuntu (xkill, System Monitor, kill -9)
    4 Min Read
  • Features
    FeaturesShow More
  • Guide
    GuideShow More
    Tips to Keep Your Cloud Storage Safe and Secure
    6 Min Read
  • Contact
  • Blog
Reading: Install a Specific Version of a Package Using Composer (Exact Version + Examples)
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Categories
    • Marketing
    • OS
    • Features
    • Guide
    • Lifestyle
    • Wellness
    • Healthy
    • Nutrition
  • More Foxiz
    • Blog Index
    • Complaint
    • Sitemap
    • Advertise
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > Install a Specific Version of a Package Using Composer (Exact Version + Examples)
Web Development

Install a Specific Version of a Package Using Composer (Exact Version + Examples)

how7o
By how7o
Last updated: January 14, 2026
5 Min Read
Install a specific version of a package using Composer (composer require vendor/package:2.1.0)
SHARE

I ran into this while working on a PHP project where everything was “fine”… until a teammate updated dependencies and my build started failing. The package itself wasn’t broken — it was the newer version that introduced a change our codebase wasn’t ready for. That’s when I needed to install a specific version of a package using Composer instead of just pulling the latest release.

Contents
  • The quick answer (exact command)
  • What actually happens when you run composer require
  • How to find available package versions
    • Option 1: Check Packagist
    • Option 2: Use Composer itself
  • Exact version vs version constraints (what I recommend)
    • Common constraint examples
  • How to downgrade to a specific version (real-world fix)
  • Troubleshooting (common Composer errors)
    • 1) “Could not find a matching version”
    • 2) Dependency conflicts
  • Helpful links (add these for Yoast)
  • Final thoughts

The fix was simple once I knew the syntax: you can tell Composer the exact version right in the composer require command. In this post, I’ll show the exact command, how to find available versions, and a few real-world tips (downgrades, conflicts, and version constraints).

Install a specific version of a package using Composer (composer require vendor/package:2.1.0)

The quick answer (exact command)

To install an exact package version with Composer, use:

composer require vendor/package:version

Example: if you want to install version 2.1.0 of example/package, run:

composer require example/package:2.1.0

Windows tip: if your terminal is picky, wrap it in quotes:

composer require "example/package:2.1.0"

What actually happens when you run composer require

Composer will do three important things:

  • Add the package + version constraint to your composer.json
  • Download the package and its dependencies
  • Update composer.lock so the installed versions stay consistent across servers and teammates

That last part (composer.lock) is the reason your production server matches your local machine. If you’re using Git, commit composer.lock too.

How to find available package versions

Before pinning a version, you need to know what versions exist. Here are the two easiest ways I use:

Option 1: Check Packagist

Go to Packagist and search the package name. You’ll see a version list (tags/releases). This is the fastest method.

Option 2: Use Composer itself

If the package is already installed (or you want more details), run:

composer show vendor/package --all

This prints available versions plus extra info. Super useful when you’re not sure what release you should pin.

Exact version vs version constraints (what I recommend)

You can install a specific version of a package using Composer in two common ways:

  • Exact version (hard pin): 2.1.0
  • Constraint (allow safe updates): ^2.1 or ~2.1

If you’re fixing a break right now, an exact version is fine. But long-term, I usually prefer a constraint so I still get bug fixes without jumping to a breaking major version.

Common constraint examples

# exact version (pin)
composer require example/package:2.1.0

# allow updates within major version (recommended in many cases)
composer require example/package:^2.1

# allow updates within minor version (more strict)
composer require example/package:~2.1

How to downgrade to a specific version (real-world fix)

This was my original problem: a newer version got installed and things broke. Downgrading is basically the same command — you just require the older version.

composer require example/package:2.1.0 --with-all-dependencies

--with-all-dependencies helps when the package needs compatible dependency versions too (this avoids a lot of “conflict” errors).

Troubleshooting (common Composer errors)

1) “Could not find a matching version”

  • Double-check the version exists (Packagist list).
  • Make sure you didn’t type 2.1 when the package only has 2.1.0 releases.
  • If it’s a dev branch, you may need something like dev-main (not recommended for production).

2) Dependency conflicts

If Composer complains about conflicts, try the require command with:

composer require example/package:2.1.0 --with-all-dependencies

If you’re working on a big framework project (Laravel/Symfony), conflicts often happen because other packages also restrict versions. In that case, you may need to update a small group of packages together.

Helpful links (add these for Yoast)

  • Composer docs: require command
  • Composer docs: version constraints
  • Packagist (PHP package repository)
  • Related: How to install Composer on Ubuntu (internal link)
Composer version install steps: find version → composer require package:version → verify → commit composer.lock

Final thoughts

Once you know the syntax, it’s straightforward to install a specific version of a package using Composer. The main rule I follow is: pin exact versions when you’re fixing a breaking change quickly, then switch to a sensible constraint so you still receive bugfix updates without surprises. And always commit composer.lock so your production server stays identical to your local setup.

TAGGED:composercomposer.jsonDependency ManagementLaravelPackagistphpSymfonyVersioning

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Include Composer packages in plain PHP projects How to Include Composer Packages in Plain PHP Projects (Autoload + Example)
Next Article Return or throw an error in Laravel (JSON response vs exception) How to Manually Return or Throw an Error Exception in Laravel
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
How I Fixed Composer Dependency Errors
How I Fixed Composer Dependency Errors Using the –ignore-platform-reqs Flag (Step-by-Step Guide)
January 12, 2026
Transfer Discourse to a new server
How to Transfer Discourse to a New Server on AlmaLinux (Backup + Restore, Step-by-Step)
January 12, 2026
Installed Discourse on AlmaLinux
How I Installed Discourse on AlmaLinux (Docker Method, Step-by-Step)
January 12, 2026
Installing Docker on AlmaLinux guide
Install Docker on AlmaLinux: Step-by-Step (Docker CE + Compose)
January 12, 2026
Change welcome message on Ubuntu VPS server (MOTD + SSH banner)
Change Welcome Message on Ubuntu VPS (MOTD + SSH Banner)
January 12, 2026

You Might Also Like

Send a simple email in Laravel using Mail::raw and SMTP
Web Development

How to Send a Simple Email in Laravel (Fast SMTP + Mail::raw)

4 Min Read
Create custom exception class in Laravel (Artisan command + secure error handling)
Web Development

How to Create a Custom Exception Class in Laravel (With Clean JSON Responses)

6 Min Read
WooCommerce homepage filter to hide out of stock products
Web Development

Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)

5 Min Read
Debug PHP like console.log using error_log and server logs
Web Development

How to Debug in PHP Like console.log (echo, error_log, WordPress debug.log)

6 Min Read

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?