Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

Installing Imagick on a Forge provisioned PHP 7 server

Today I set up some PHP 7 servers on Forge. Those servers are going to be used to host some Blender based projects. Blender uses laravel-medialibrary to convert images. The package uses Imagick to do that. It turns out the Imagick PHP 7 extension isn’t released yet. But there’s an RC2 release candidate. Pascal Baljet provided this script to compile and install the extension.

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"

apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget http://pecl.php.net/get/imagick-3.4.0RC2.tgz
tar xvzf imagick-3.4.0RC2.tgz
cd imagick-3.4.0RC2
make install
rm -rf /tmp/imagick-3.4.0RC2*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
service php7.0-fpm restart
service nginx restart

I was a bit worried that the extension would be unstable, but all image manipulations that I need on my projects (cropping and resizing some stuff), just worked. Mandatory disclaimer: your mileage may vary.

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band. He loves waffles and butterflies.