In this tutorial, we’ll learn how to install and use Composer.
Composer is a PHP dependency manager that simplifies adding and managing libraries in your PHP projects.
After Composer has been installed you can use it by opening cmd then navigating to the project where you want to add your dependencies. In this case, I want to use PHPMailer in my project to send emails.
Note: You can find all sorts of other libraries here.
A dependency can be simply added like so: composer require phpmailer/phpmailer
If you now take a look in your project directory you will see that some files were added. To use your dependencies you must first require() the Composer autoload.php file located inside the vendor folder. Then you can use the use keyword to specify what dependencies you will be needing.