How to install Composer packages in custom directory

When we install packages using composser. It just basically creates a new directory called vendor and install all the packages in it.

Most of the time we may need to change its location.

You can do that by using vendor-dir

Here’s a composer.json file where I’ve changed its directory

  "require": {
    "sendgrid/sendgrid": "~3.2"
  "config": {
        "vendor-dir": "backend/vendor/"