Laravel Advanced: Lesser-Known, Yet Useful Composer Commands
Tags: laravel, php, learning, productivity
Published: 2024-06-02 13:43:59

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.

![image](https://i.postimg.cc/2SpGpWvk/image.png)

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.

```bash
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.

```bash
composer show
```

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

```bash
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.

```bash!
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.

```bash!
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.

```bash
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](https://twitter.com/laravelbackpack); 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](https://backpackforlaravel.com/articles/tips-and-tricks/laravel-advanced-top-5-scheduler-functions-you-might-not-know-about). Keep exploring, and keep coding with ease using Laravel. Until next time, happy composing! 🚀