Laravel Advanced: Lesser-Known, Yet Useful Composer Commands

Karan DatwaniKaran Datwani
2 min read

Composer is the go-to dependency manager for PHP, and if you're working with Laravel, you're already familiar with frequently used commands like composer install and composer update. Composer also offers some commands that are lesser-known but helpful while working on your Laravel app.

Here are five Composer commands you might not know but would love to use.

1. composer outdated

Ever wondered which of your app dependencies are outdated? composer outdated gives you a quick rundown of all packages that have newer versions available. This is especially useful for keeping your project up-to-date and secure.

composer outdated

This lists all the outdated packages in your project, showing the current and latest versions. It's a handy way to stay on top of updates without blindly running composer update.

2. composer show

Need an overview of the installed packages? The composer show displays information about all the packages installed in your project.

composer show

You can also use it to get details about a specific package by passing the package name:

composer show vendor/package
# Example: composer show backpack/crud

It’s a great way to quickly check the installed version, description, and dependencies of any package in your project.

3. composer why

Wanna figure out why a particular package is installed? composer why helps you trace the dependency tree to understand which package requires it.

composer why vendor/package

4. composer licenses

Wanna know the licenses of the packages you are using? composer licenses provides a summary of all the licenses of the installed dependencies. This is useful for ensuring compliance with open-source licenses.

composer licenses

5. composer check-platform-reqs

Checking all required PHP extensions are installed can be a hassle while working on a project across multiple environments. The composer check-platform-reqs command checks if your platform meets the package requirements.

composer check-platform-reqs

This command verifies that the PHP version and all required extensions are installed and meet the version constraints specified in your composer.json.

Conclusion

While basic Composer commands get the job done, these lesser-known commands can save you time and hassle by giving you deeper insights and more control over your project's dependencies. So, the next time you fire up your terminal, try these commands and see how they can improve your Laravel experience.

All of the above have been previously shared on our Twitter, one by one. Follow us on Twitter; You'll ❤️ it. You can also check the first article of the series, which is on the Top 5 Scheduler Functions you might not know about. Keep exploring, and keep coding with ease using Laravel. Until next time, happy composing! 🚀

0
Subscribe to my newsletter

Read articles from Karan Datwani directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Karan Datwani
Karan Datwani