How do I manage Composer for Laravel using the Web Terminal?

Procédure

Composer is a dependency manager for PHP that lets you install, update and manage the libraries needed for your Laravel application. With Composer, you can easily integrate and maintain the required components, ensuring efficient and consistent management of your project's dependencies.

In this documentation, we will explain how to interact with Composer using command lines on the Web Terminal.

Prior to this documentation, we invite you to access your hosting's Web Terminal.

Using the Composer command

Installing dependencies

If you already have a Laravel project and need to install the dependencies listed in the composer.json file, use :

compose install

Updating dependencies

To update all the dependencies in your Laravel project to their latest compatible versions, use :

composer update

Adding new dependencies

To add a new dependency to your project, use the require command. For example, to add guzzlehttp/guzzle:

composer require guzzlehttp/guzzle

Removing dependencies

To remove a dependency from your project, use the remove command. For example, to remove guzzlehttp/guzzle:

composer remove guzzlehttp/guzzle

Optimising automatic loading

To optimise the automatic loading of classes, which can improve the performance of your application, use :

composer dump-autoload -o

Displaying installed dependencies

To see a list of all installed dependencies and their versions, use :

composer show

Delete the Composer cache

To delete the Composer metadata cache

composer clear-cache

Search for packages

Searches for available packages in the Composer registry using a keyword.

composer search [keyword]

Composer documentation: https: //getcomposer.org/

Conclusion

You now know how to :

  • Install the dependencies of your Laravel project with composer install.
  • Update your dependencies to the latest compatible versions with composer update.
  • Easily add new libraries to your project with composer require.
  • Remove unnecessary dependencies with composer remove.
  • Optimise automatic class loading with composer dump-autoload -o for better performance.
  • View the list of installed packages and their versions with composer show.
  • Clear the Composer cache to resolve certain problems using composer clear-cache.
  • Search for specific packages using composer search [keyword].

✨ Thanks to this guide, managing your PHP project's dependencies with Composer becomes child's play! We hope this information will help you maintain and develop your applications more efficiently and confidently. 🚀

Many thanks for reading! Feel free to leave a comment to share your experience with Composer or ask questions if you have any. We want to hear what you think! 💬

help.lws.net/a/1920
Was this article helpful?

Yes

No

Read 11 318 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

RGPD : Responsable LWS-Ligne Web Services. Finalité : modération et publication publique de votre question, notification éventuelle d'une réponse. Base légale : consentement (art. 6.1.a RGPD). Conservation des emails : 90 jours après notification, 12 mois maximum sans réponse. Vous pouvez exercer vos droits via notre nos CGV - section RGPD.