Those of you with MAMP who work with laravel will be very familiar with this dreaded message when attempting to php artisan tinker:
Boris REPL not supported. Needs readline, posix, and pcnt extensions.
Below I explain how to install these tools.
1. Install Boris
This ones the easiest to get of the three. You’ll need homebrew:
1 | brew install boris |
2. Prepare PHP source
To get the two PHP extensions, we’ll need to compile them from source and set them up in MAMP. Don’t worry, this is actually surprisingly easy!
Determine your PHP version:
1 2 3 4 | $ php -v PHP 5.6.2 (cli) (built: Oct 20 2014 16:21:27) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies |
Download and Extract
Here I have 5.6.2 installed so download, extract and move it to MAMP’s respective includes folder:
1 2 3 4 5 | wget http://museum.php.net/php5/php-5.6.2.tar.gz tar -xzvf php-5.6.2.tar.gz mv php-5.6.2 php mkdir -p /Applications/MAMP/bin/php/php5.6.2/include mv php /Applications/MAMP/bin/php/php5.6.2/include |
Configure
First we prepare all the necessary header files:
1 2 | cd /Applications/MAMP/bin/php/php5.6.2/include/php ./configure |
Then set some flags so things will work with 32 and 64-bit architecture (as MAMP PHP was built this way):
1 2 3 4 5 6 | MACOSX_DEPLOYMENT_TARGET=10.10 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET |
3. Compile & Install Pcntl and Readline
Compilation
To get this happening you’ll need autoconf if you don’t already have it:
1 | brew install autoconf |
Now for the actual compiling:
1 2 3 4 5 6 7 8 9 10 | cd ext/pcntl phpize ./configure make cp modules/pcntl.so /Applications/MAMP/bin/php/php5.6.2/lib/php/extensions/no-debug-non-zts-20131226 cd ../readline phpize ./configure make cp modules/readline.so /Applications/MAMP/bin/php/php5.6.2/lib/php/extensions/no-debug-non-zts-20131226 |
Installation
Open MAMP and go to File – Edit Template – PHP – PHP 5.6.2 php.ini and find the area starting with
1 2 3 | ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; |
You’ll see a few extension=pgsql.so style lines. Below them drop
1 2 | extension=pcntl.so extension=readline.so |
Save and close the file, restart apache and you’re done!
Many thanks to Linh M. Tran for almost all the information in this post.