Composer failed to install Laravel because of missing zip extension

I was trying to install Laravel by running the command composer global require laravel/installer but it failed because laravel/installer v2.0.x requires ext-zip.

Turns out it wasn’t installed on my system. To fix it, first find out your php version by running php -v. Then use the php version number to install the missing extension like php7.2-zip

sudo apt install php7.2-zip

This will also work for other extensions like php7.2-mbstring and php7.2-dom