Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Premium Members Only
Join to unlock this tutorial and all of our courses.
Tutorial Premium Tutorial

Composer in Laravel: 9 Useful Features

April 27, 2023
7 min read

Composer is a well-known tool to manage PHP project dependencies. But I'm pretty sure you're not using all of its features! In this tutorial, we'll show many less-known capabilities of Composer.


1. Versioning Syntax Options

Do you know the difference between the 1.3.*, ^1.3, and ~1.3 versions?

Composer uses quite a complex versioning system with a variety of operators. Let's look at the most common syntax options:

{
"vendor/package": "1.3.2", // exactly 1.3.2
"vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
"vendor/package": "<1.3.2", // anything below 1.3.2
"vendor/package": "1.3.*", // >=1.3.0 <1.4.0
"vendor/package": "1.*", // >=1.0.0 <2.0.0
"vendor/package": "~1.3.2", // >=1.3.2 <1.4.0
"vendor/package": "~1.3", // >=1.3.0 <2.0.0
"vendor/package": "^1.3.2", // >=1.3.2 <2.0.0
"vendor/package": "^0.3.2", // >=0.3.2 <0.4.0
"vendor/package": "^1.1.0", // >=1.1.0 <2.0.0
}

There are more combinations supported by Composer, but you will mostly encounter these.


2. Check Outdated Packages

You might want to double-check which packages have newer versions, without actually running composer update. Run this:

composer outdated

And it will give you a list of packages with newer versions:

In this list, you can see all the direct packages that have newer versions available. Some of them will automatically update with the composer update command, but some of them might require manual version change.


3. Bumping Versions

Last year Composer introduced a new command composer bump. Its main job is...

Premium Members Only

This advanced tutorial is available exclusively to Laravel Daily Premium members.

Premium membership includes:

Access to all premium tutorials
Video and Text Courses
Private Discord Channel

Comments & Discussion

ZA
Zain Amin ✓ Link copied!

Great...!!!

KJ
Kevin Jiang ✓ Link copied!

Thank you! Really helpful!

F
Faraz ✓ Link copied!

Thanks. Composer has always something to learn. I did not know about the "--optimize-autoloader" flag. Great read!

AN
Al Nahian ✓ Link copied!

That was great! Learned something new today, cool!

P
Polfo ✓ Link copied!

composer status

Shows a list of locally modified packages. Checks for local modifications of files (when you edit something locally but did not yet push and configure it to your own branch). Run this command before a composer update to prevent losing your changes.

JL
Justin Loffler ✓ Link copied!

In the composer section. "vendor/package": "^0.3.2", would be can be any version greater than or equal to 0.3.2 but less than 1.0.0.

O
Oleksandr ✓ Link copied!

This section in the article is correct 😉. Versions before 1.0 have a bit different range of rules. Please, check it out in the composer docs and the summary.

D
dodofix ✓ Link copied!

nice and clean :)

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.