0

Am trying to install swoole using PHP 7.0.2 in MAMP

$ pecl install swoole
Could not open input file:/app/MAMP/bin/php/php7.0.2/lib/php/peclcmd.php

Is there any alternate way to install it? Thanks.

Sumithran
  • 6,217
  • 4
  • 40
  • 54

1 Answers1

3

I have no luck installing Swoole via home brew or pecl. So I installed it manually and works. So here my step:

Make sure you php installed on your osx

php -v

phpize -v

Go to temporary folder

cd /tmp/

Download the source code

wget "https://github.com/swoole/swoole-src/archive/v4.0.3.tar.gz" -O swoole.tar.gz

Extract the file

tar xvzf swoole.tar.gz

Go to source folder

cd swoole-src-4.0.3/

Prepare the build environment for a PHP extension

phpize

Add configuration paramaters as needed

./configure

Run make. This will take some time a successful result of make is module/swoole.so

make

create Swoole extension directory

mkdir -p /usr/local/opt/php71-swoole/

install the swoole into the PHP extensions directory

cp modules/swoole.so /usr/local/opt/php71-swoole/

Create config file for Swoole

touch /usr/local/etc/php/7.1/conf.d/ext-swoole.ini
echo "extension=/usr/local/opt/php71-swoole/swoole.so" > /usr/local/etc/php/7.1/conf.d/ext-swoole.ini

check if the swoole extension has been enabled php -m | grep swoole

If succeed, it will send you output something like "swoole"

PS: I run PHP 7.1 and Swoole 4.0.3. Adjust it with your own version.

ikandars
  • 486
  • 5
  • 5