How to set a Default Vendor Name for your Composer Packages

2020-05-09

When initializing a composer package with composer init you are asked for a vendor/package-name. I used to type this out all the time, but today I learned how to set a default value for the vendor name.

With the following fine line of magic you can set a default vendor name for your packages, that composer will use as default value for your packages. Add this to your ~/.bashrc and you don't have to type out your vendor/package-name each time you run composer init.

vim ~/.bashrc

# ...

# set custom composer vendor name (tjventurini)
export COMPOSER_DEFAULT_VENDOR=tjventurini

Now when you run composer init you should already see something like the following prefilled.

Package name (<vendor>/<name>) [tjventurini/package-name]: 

The package name will come from the directory your are in.

Awesome!

Source: stackoverflow.com (opens new window)