[ext-mbstring, ex-dom] How to Install missing PHP Packages/Extensions in Ubuntu?

While installing Composer in Ubuntu, following issue was encountered during the installation of composer.

Issue Encountered

Loading composer repositories with package information Installing dependencies (including require-dev) from lock file. Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for phar-io/manifest 1.0.3 -> satisfiable by phar-io/manifest[1.0.3].
- phar-io/manifest 1.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 2
- Installation request for phpunit/php-code-coverage 6.1.4 -> satisfiable by phpunit/php-code-coverage[6.1.4].
- phpunit/php-code-coverage 6.1.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 3
- Installation request for phpunit/phpunit 7.5.2 -> satisfiable by phpunit/phpunit[7.5.2].
- phpunit/phpunit 7.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 4
- Installation request for theseer/tokenizer 1.1.0 -> satisfiable by theseer/tokenizer[1.1.0].
- theseer/tokenizer 1.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.

Log speaks for itself.
phar-iorequires ext-dom
phpunit/php-code-coverage 6.1.4 requires ext-dom
theseer/tokenizer 1.1.0 requires ext-dom

Resolution

As the log speaks we need to install the extension dom. This is how we do it:

sudo apt install php7.1-dom

If the log shows only one extension missing, than above command works. If there are other extension missing, you can add those extension in the same line like shown below:

sudo apt install php7.1-dom php7.1-ext-mbstring

That’s it. Now you won’t have any issues in installing  composer. Enter composer install

%d bloggers like this: