1

I'm on OSX High Sierra and trying to install php56-imagick via brew install php56-imagick. This results in:

Error: No available formula with the name "php56-imagick" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

I tried this as read on the internet brew tap Homebrew/homebrew-php but it returns: Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated..

Where can I find the formula to install this package?

Thanks, Kim

bfontaine
  • 18,169
  • 13
  • 73
  • 107
Kim
  • 1,757
  • 1
  • 17
  • 32
  • 1
    I wrote an explanation here... https://stackoverflow.com/a/50529784/2836621 – Mark Setchell Jul 27 '18 at 18:34
  • Possible duplicate of [Homebrew: install new formula php72-imagick](https://stackoverflow.com/questions/50060021/homebrew-install-new-formula-php72-imagick) – bfontaine Aug 17 '18 at 08:20

1 Answers1

0

php56-imagick and other PHP extensions used to be available in the Homebrew/php tap, but they have been deprecated. The standard way to install PHP extension is to use pecl, for example:

pecl install imagick

Installing Extensions for Specific Version of PHP

The formula php56-imagick assumes you need the extension for PHP 5.6. Add PHP 5.6's installation directory into your PATH so that you are using the correct version of pecl.

$ PATH=/usr/local/opt/php@5.6/bin:/usr/local/opt/php@5.6/sbin:$PATH pecl install imagick
downloading imagick-3.4.3.tgz ...
Starting to download imagick-3.4.3.tgz (245,410 bytes)
...................................................done: 245,410 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
...
...
...
Build process completed successfully
Installing '/usr/local/Cellar/php@5.6/5.6.35_1/include/php/ext/imagick/php_imagick_shared.h'
Installing '/usr/local/Cellar/php@5.6/5.6.35_1/pecl/20131226/imagick.so'
install ok: channel://pecl.php.net/imagick-3.4.3
Extension imagick enabled in php.ini

Extension Installation Error

During my extension installation process, I encountered this error

ERROR: failed to mkdir /usr/local/Cellar/php@7.1/7.1.16_1/pecl/20160303

Which is due to the missing /usr/local/lib/php/pecl directory. This might be because I have been using PHP 5.x before the release of PHP 7, hence the newer installation does not create the directory. In any case, creating the directory solved this problem

mkdir /usr/local/lib/php/pecl

Compiled Extension Directory

Note that every version of PHP (installed via Homebrew) is located at /usr/local/lib/php/pecl

$ ls -ld /usr/local/Cellar/php@5.6/5.6.35_1/pecl
lrwxr-xr-x  1 hanxue  admin  23 Apr 25  2018 /usr/local/Cellar/php@5.6/5.6.35_1/pecl -> /usr/local/lib/php/pecl

Each PHP version will have their own extension directory

$ ls /usr/local/lib/php/pecl/20131226/
imagick.so

php.ini Extension Configuration

pecl helpfully add the line

 extension="imagick.so"

to the top of php.ini, but `extension_dir is unset. Set it to the correct value

extension_dir = "/usr/local/lib/php/pecl/20131226"

Finally, remember to reload or restart your web server!

Hanxue
  • 12,243
  • 18
  • 88
  • 130