Installing Composer A PHP Dependency Manager

composer
Share:

About

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.

Install Process:

You can download the Composer installer from here.

Using Composer:

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.
Share:

Leave a Reply

Your email address will not be published.

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger