How to install gRPC extension on your MAC computer?
There is couple of steps you would need to perform, in this tutorial we will go one by one.
If you are not familiar with gRPC, please read official documentation about it:
Check do you have it already, type this in your terminal window
in the printed list check do you have grpc module, if not try to install it with this command:
sudo pecl install grpc
and if you get this error: Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
we would have to first fix autoconf issue.
Here is the lists of commands to install it:
go to your project folder and grab it with curl:
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
extract it and make it:
tar xzf autoconf-latest.tar.gz
if you get this error xcrun: error: invalid active developer path you would have to download and install the Command Line Tools package and fix the problem:
After that you could get this popup:
Accept it and wait until it is installed
Now run this command again (note: you should be in cd autoconf-* folder still) :
and then run make command
sudo make install
ok, now we can run again sudo pecl install grpc to finally install gRPC extension:
sudo pecl install grpc
this will take some time, so go and drink a ☕️ and wait until is finished...
OK, now when it is finished you should see this message:
Build process completed successfully
install ok: channel://pecl.php.net/grpc-1.35.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=grpc.so" to php.ini
And now we have to enable it in our php.ini
To locate your php ini file, type this:
php -i | grep 'Configuration File'
in my case, location is:
Loaded Configuration File => /usr/local/php5/lib/php.ini
so let's add our grpc.so to it:
login as admin:
add php extension by using the command line:
echo "extension=grpc.so" >> /usr/local/php5/lib/php.ini
restart the apache
cool, now if you type php - m you should see grpc in your list of enabled modules.
easy peasy lemon squeezy 😀