Can't install PhpSpreadsheet by composer [duplicate] - composer-php

I newly install Dompdf in Laravel Project via Composer (composer require barryvdh/laravel-dompdf). After enter the Command Terminal Reply Following Errors.
Problem 1
- dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
- barryvdh/laravel-dompdf v0.7.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0].
- Installation request for barryvdh/laravel-dompdf ^0.7.0 -> satisfiable by barryvdh/laravel-dompdf[v0.7.0].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/5.6/cli/php.ini
- /etc/php/5.6/cli/conf.d/10-opcache.ini
- /etc/php/5.6/cli/conf.d/10-pdo.ini
- /etc/php/5.6/cli/conf.d/15-xml.ini
- /etc/php/5.6/cli/conf.d/20-calendar.ini
- /etc/php/5.6/cli/conf.d/20-ctype.ini
- /etc/php/5.6/cli/conf.d/20-dom.ini
- /etc/php/5.6/cli/conf.d/20-exif.ini
- /etc/php/5.6/cli/conf.d/20-fileinfo.ini
- /etc/php/5.6/cli/conf.d/20-ftp.ini
- /etc/php/5.6/cli/conf.d/20-gettext.ini
- /etc/php/5.6/cli/conf.d/20-iconv.ini
- /etc/php/5.6/cli/conf.d/20-json.ini
- /etc/php/5.6/cli/conf.d/20-mbstring.ini
- /etc/php/5.6/cli/conf.d/20-phar.ini
- /etc/php/5.6/cli/conf.d/20-posix.ini
- /etc/php/5.6/cli/conf.d/20-readline.ini
- /etc/php/5.6/cli/conf.d/20-shmop.ini
- /etc/php/5.6/cli/conf.d/20-simplexml.ini
- /etc/php/5.6/cli/conf.d/20-sockets.ini
- /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
- /etc/php/5.6/cli/conf.d/20-sysvsem.ini
- /etc/php/5.6/cli/conf.d/20-sysvshm.ini
- /etc/php/5.6/cli/conf.d/20-tokenizer.ini
- /etc/php/5.6/cli/conf.d/20-wddx.ini
- /etc/php/5.6/cli/conf.d/20-xmlreader.ini
- /etc/php/5.6/cli/conf.d/20-xmlwriter.ini
- /etc/php/5.6/cli/conf.d/20-xsl.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
How to Solve this Error
I already Installed GD using Following comment. sudo apt-get install php5-gd and also Apache Server Restarted. My Laravel Version is 5.3 and Ubuntu Version is 14.04

I have installed php7, I did the following to solve exactly the same error
sudo apt-get install php7.0-gd
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-xsl

If you are working in PHP version 5.* then you have to install
sudo apt-get install php5-gd
And if you are working in PHP version 7.* then you have to install
sudo apt-get install php7.0-gd
Hope it will work...
And if you are working in PHP version 7.2 then you have to install
sudo apt-get install php7.2-gd... it worked for me

For php-8, just locate your php.ini file and uncomment the line extension=gd
Below is a picture guide for those using Xampp and Windows
Step 1: Open php.ini or locate it in your machine (C:/xampp/php/php.ini)
Step 2: Uncomment the line extension=gd by removing the semicolon
Step 3: Save your file and restart your services

Open your php.ini and uncomment this line:
;extension=php_gd2.dll

It may not be enabled for php-cli, you can enable like this;
sudo phpenmod gd
UPDATE
I guess, you are using ppa:ondrej php package (5.6), which is confusing you with default ubuntu 14.04 php package (5.5.9).
To install php 5.6 gd library from ppa:ondrej, you should use:
sudo apt-get install php5.6-gd

PHP 7.4.2 (cli) (built: Feb 5 2020 16:50:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
For Php 7.4.2
sudo apt-get install php7.4-gd
sudo phpenmod gd

Before installing the missing dependency, you need to check which version of PHP is installed on your system.
php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
In this case it's php7.2. apt search php7.2 returns all the available PHP extensions.
apt search php7.2
Sorting... Done
Full Text Search... Done
libapache2-mod-php7.2/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
server-side, HTML-embedded scripting language (Apache 2 module)
libphp7.2-embed/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
HTML-embedded scripting language (Embedded SAPI library)
php-all-dev/bionic,bionic 1:60ubuntu1 all
package depending on all supported PHP development packages
php7.2/bionic-updates,bionic-updates,bionic-security,bionic-security 7.2.10-0ubuntu0.18.04.1 all
server-side, HTML-embedded scripting language (metapackage)
php7.2-bcmath/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Bcmath module for PHP
php7.2-bz2/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
bzip2 module for PHP
php7.2-cgi/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
server-side, HTML-embedded scripting language (CGI binary)
php7.2-cli/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
command-line interpreter for the PHP scripting language
php7.2-common/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
documentation, examples and common module for PHP
php7.2-curl/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
CURL module for PHP
php7.2-dba/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
DBA module for PHP
php7.2-dev/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Files for PHP7.2 module development
php7.2-enchant/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Enchant module for PHP
php7.2-fpm/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.2-gd/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
GD module for PHP
php7.2-gmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
GMP module for PHP
php7.2-imap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
IMAP module for PHP
php7.2-interbase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Interbase module for PHP
php7.2-intl/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Internationalisation module for PHP
php7.2-json/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
JSON module for PHP
php7.2-ldap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
LDAP module for PHP
php7.2-mbstring/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
MBSTRING module for PHP
php7.2-mysql/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
MySQL module for PHP
php7.2-odbc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
ODBC module for PHP
php7.2-opcache/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
Zend OpCache module for PHP
php7.2-pgsql/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
PostgreSQL module for PHP
php7.2-phpdbg/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
server-side, HTML-embedded scripting language (PHPDBG binary)
php7.2-pspell/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
pspell module for PHP
php7.2-readline/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
readline module for PHP
php7.2-recode/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
recode module for PHP
php7.2-snmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
SNMP module for PHP
php7.2-soap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
SOAP module for PHP
php7.2-sqlite3/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
SQLite3 module for PHP
php7.2-sybase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Sybase module for PHP
php7.2-tidy/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
tidy module for PHP
php7.2-xml/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.2-xmlrpc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
XMLRPC-EPI module for PHP
php7.2-xsl/bionic-updates,bionic-updates,bionic-security,bionic-security 7.2.10-0ubuntu0.18.04.1 all
XSL module for PHP (dummy)
php7.2-zip/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
Zip module for PHP
You can now proceed to installing the missing dependency by running:
sudo apt install php7.2-gd

if you are working in PHP version 7.2 then you have to install
sudo apt-get install php7.2-gd

For php 7.1
sudo apt-get install php7.1-gd
Cheers!

I'm working on php 8.0.9, and I just uncomment this on php.ini in xampp/php/php.ini directory.
from
;extension=gd
to
extension=gd
and it's work normal again

The solution is quite simple.
In your php.ini, just uncomment the line extension=php_gd2.dll (or .so extension for unix systems.)
Hope it helps.

This worked for me:
composer require "ext-gd:*" --ignore-platform-reqs

As of Composer 2.0 on Arch, I use: --ignore-platform-req=ext-gd
Eg:
php composer install -n --ignore-platform-req=ext-gd
Eg: (to ignore multiple requirements)
php composer install -n --ignore-platform-req=ext-gd --ignore-platform-req=ext-ldap
Ignoring Composer requirements may be necessary because Composer may return false warnings on dependencies that are already properly installed and enabled, consider this Arch forum article:
I have installed php-gd and uncommeted extension=gd.so in /etc/php/php.ini as the wiki says
Thanks for this answer on a related Question, How to always use ignore-platform-reqs flag when running composer?

Using Manjaro(Arch) Linux:
$ sudo pacman -S php-gd
In file /etc/php/php-ini, add the line:
extension=gd.so

For Windows :
Uncomment this line in your php.ini file
;extension=php_gd2.dll
If the above step doesn't work uncomment the following line as well:
;extension=gd2

sudo apt-get install php7.4-zip
Use your version of php. Like here I used 7.4

CentOS
sudo yum install php-gd
Unbuntu
sudo apt install php-gd

First Check your php version
sudo php -v
Then install php gd package of relevent version.
sudo apt-get install php${version}-gd
Finally run
composer update

On CentOS 7, try running following command:
sudo yum install php72u-gd.x86_64

in docker I found a same problem, even after
"rm /etc/apt/preferences.d/no-debian-php"
then
"apt update"
"apt install php7.4-gd"
"php composer.phar update"
error " ..... ext-gd ....."
so my solution is direct using php7.4
"php7.4 composer.phar update"
and its work. I dont know why.

It may help you
apt install php-xml
systemctl restart apache2
From reference here, you may learn in brief.
Thanks :)

On Local or Xampp in windows
go to : C:\xampp\php\php.ini
uncomment extension=gd

PHP VERSION - 7.3.21
WAMP SERVER
// use below command to fix ext-gd issue
// work for me
composer require "ext-gd:*" --ignore-platform-reqs phpoffice/phpspreadsheet

Related

The specified module could not be found.)) in Unknown on line 0

I am new to Laravel. I want to composer install the code but I get the error. Does anyone know how to solve it?
Problem 1
- Root composer.json requires php-mime-mail-parser/php-mime-mail-parser ^7.0 -> satisfiable by php-mime-mail-parser/php-mime-mail-parser[7.0.0].
- php-mime-mail-parser/php-mime-mail-parser 7.0.0 requires ext-mailparse * -> it is missing from your system. Install or enable PHP's mailparse extension.
To enable extensions, verify that they are enabled in your .ini files:
- D:\wamp64\bin\php\php7.3.21\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
The mailparse extension does not yet support PHP 7.3 or 7.4.
You need change your PHP version
https://serverpilot.io/docs/how-to-install-the-php-mailparse-extension/
Install Mailparse on PHP 7.0, 7.1, or 7.2
To install this extension on PHP 7.X, SSH in to your server as root and run the following commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo pecl7.X-sp install --nodeps mailparse
sudo bash -c "echo extension=mailparse.so > /etc/php7.X-sp/conf.d/mailparse.ini"
sudo service php7.X-fpm-sp restart

How can I use xdebug 3.0 with PHP 7.3 or 7.4 in DDEV?

DDEV-Local v1.16.2 ships with xdebug 3.0 as the xdebug version for PHP8.0 (as of Dec 2020, DDEV-Local v1.16), but I'd like to try out xdebug 3.0 with PHP7.3 or 7.4. How could I do that?
EDIT 2020-12-13: DDEV-Local v1.16.3 ships with Xdebug 3.0.1 as the Xdebug version for PHP7.2/3/4 and PHP8.0
EDIT 2020-12-13: DDEV-Local v1.16.3 ships with Xdebug 3.0.1 as the Xdebug version for PHP7.2/3/4 and PHP8.0, so you don't have to do anything at all!
DDEV-Local depends on the deb.sury.org Debian packages for PHP, so will follow those as the changes are made. Currently deb.sury.org packages PHP8.0 with xdebug 3.0, but it's not hard to get xdebug 3.0 with earlier PHP versions until that changes.
You can compile and install xdebug 3.0 for PHP7.3 or 7.4. Place this file as .ddev/web-build/Dockerfile in your project's .ddev directory:
ARG BASE_IMAGE
FROM $BASE_IMAGE
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests php-dev php-pear build-essential
RUN pecl install xdebug
RUN cp /etc/php/8.0/mods-available/xdebug.ini /etc/php/7.4/mods-available/xdebug.ini
RUN cp /etc/php/8.0/mods-available/xdebug.ini /etc/php/7.3/mods-available/xdebug.ini

PHP7 : install ext-dom issue

I'm running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error:
pish#let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^4.2 for cviebrock/eloquent-sluggable
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- Installation request for phpunit/php-code-coverage (installed at 4.0.7) -> satisfiable by phpunit/php-code-coverage[4.0.7].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gd.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mbstring.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
I have no problem installing this package on local version of the app .
First of all, read the warning! It says do not run composer as root!
Secondly, you're probably using Xammp on your local which has the required php libraries as default.
But in your server you're missing ext-dom. php-xml has all the related packages you need. So, you can simply install it by running:
sudo apt-get update
sudo apt install php-xml
Most likely you are missing mbstring too. If you get the error, install this package as well with:
sudo apt-get install php-mbstring
Then run:
composer update
composer require cviebrock/eloquent-sluggable
sudo apt install php-xml will work but the thing is it will download the plugin for the latest PHP version.
If your PHP version is not the latest, then you can add version in it:
# PHP 7.1
sudo apt install php7.1-xml
# PHP 7.2:
sudo apt install php7.2-xml
# PHP 7.3
sudo apt install php7.3-xml
# PHP 7.4
sudo apt install php7.4-xml
# PHP 8
sudo apt install php-xml
For CentOS, RHEL, Fedora:
$ yum search php-xml
============================================================================================================ N/S matched: php-xml ============================================================================================================
php-xml.x86_64 : A module for PHP applications which use XML
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-xmlseclibs.noarch : PHP library for XML Security
php54-php-xml.x86_64 : A module for PHP applications which use XML
php54-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php55-php-xml.x86_64 : A module for PHP applications which use XML
php55-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php56-php-xml.x86_64 : A module for PHP applications which use XML
php56-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php70-php-xml.x86_64 : A module for PHP applications which use XML
php70-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php71-php-xml.x86_64 : A module for PHP applications which use XML
php71-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php72-php-xml.x86_64 : A module for PHP applications which use XML
php72-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php73-php-xml.x86_64 : A module for PHP applications which use XML
php73-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
Then select the php-xml version matching your php version:
# php -v
PHP 7.2.11 (cli) (built: Oct 10 2018 10:00:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# sudo yum install -y php72-php-xml.x86_64
you need just update your local composer file:
first you need remove "composer.lock" file from you app
then, exec in your bash:
composer update --ignore-platform-req=ext-curl
so try again
composer require cviebrock/eloquent-sluggable

How do I install mcrypt extension for php 7.1 on MacOS 12 for Laravel development?

This is driving me crazy and following all the online tutorials hasn't helped.
I have just upgraded to a new mac running MacOS Sierra (10.12.1) and am trying to get my development environment configured. However, whenever I run composer update or composer install on my project I get the following message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20131226/mcrypt.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20131226/mcrypt.so, 9): image not found in Unknown on line 0
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 laravel/framework v5.0.35 -> satisfiable by laravel/framework[v5.0.35].
- laravel/framework v5.0.35 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
Problem 2
- laravel/framework v5.0.35 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
- tom-lingham/searchy 2.0.10 requires illuminate/support 5.* -> satisfiable by laravel/framework[v5.0.35].
- Installation request for tom-lingham/searchy 2.0.10 -> satisfiable by tom-lingham/searchy[2.0.10].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php.ini
I have run brew install mcrypt and it is already installed.
Warning: mcrypt-2.6.8 already installed
The system is running php 7.1 so I have also run brew install php71-mcrypt
extension=mcrypt.so has been included in the php.ini files, both on my machine and I have tried it inside the vagrant machine.
Any help would be much appreciated as I have been at this for 2 days now!
Since you are running vagrant, you need to install mcrypt within the vagrant machine. check which version of php you have installed on vagrant and install mcrypt using
sudo apt-get install *{mcrypt-version-here}*
restart apache using
sudo service apache2 restart
I had troubles of installing mcrypt-1.0.3 with PHP 7.1 on MacOS 12 Monterey.
~/projects/rest-api php -v
PHP 7.1.33 (cli) (built: Jun 7 2022 17:45:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
pecl install mcrypt-1.0.3 and pecl install --force mcrypt-1.0.3 failed with next error:
...
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/private/tmp/pear/temp/mcrypt/configure --with-php-config=/opt/homebrew/opt/php#7.1/bin/php-config --with-mcrypt' failed
But I managed to install it with next command:
pecl install --force mcrypt-1.0.3 <<<"$(ls -d $(brew --prefix)/Cellar/mcrypt/* | tail -1)"
Last lines of result:
...
Build process completed successfully
Installing '/opt/homebrew/Cellar/php#7.1/7.1.33_4/pecl/20160303/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.3
Extension mcrypt enabled in php.ini
~/projects/rest-api php -m | grep mcrypt
mcrypt
Please see solution source.

Linode Ubuntu 16 for PHP 5?

I was trying to install PHP 5.x on Linode, but I got error:
E: Package 'php5-fpm' has no installation candidate
The command line is
sudo apt-get install php5-fpm
This issue has nothing to do with Linode. If you're running Ubuntu 16.04 (not 16) on Linode or anywhere else, PHP 5 no longer is available as they have moved on to PHP 7. If you can, I'd suggest using PHP 7. If not, this answer as details on how you can install PHP 5 from a PPA for use on Ubuntu 16.04: https://askubuntu.com/a/756901/51244
Ubuntu 16.04 has php 7 installed as default.
Change php version in your command. Here is updated command
sudo apt-get install php7.0-fpm
Note php7.0 in command.

Resources