How to solve PHP cannot find php_grpc.dll extension in gRPC installation on windows #7

How to install or enable the gRPC (php_grpc.dll) extension in PHP to meet requirement for Google Cloud PHP Firestore package in Windows and Linux Operating System.

For Windows Platform:

Visit the official PECL website https://pecl.php.net/package/grpc for downloading the gRPC dll file directly. (PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.)

Now you have to select latest version (in our case 1.27.0) and stable state and in the downloads section, you have to click of DLL link


On click of DLL link, you will have option of different php version


Now you have to select as per your PC configuration and PHP version. The most default case will have 64 bit Thread Safe. So will click on link 7.4 Thread Safe (TS) x64.

It will download a zip folder name "php_grpc-1.27.0-7.4-ts-vc15-x64.zip". Just extract it and you will get three files.

You have to copy php_grpc.dll and place in your extension folder of PHP. Suppose you use xampp, then you have to place this dll in the folder C:\xampp\php\ext.

Then you have to add extension=php_grpc.dll in the php ini file.
C:\xampp\php\php.ini

Just to restart the service and you will find the grpc in php info page.

Your windows pc is ready for grpc extension.


For Linux Ubuntu Platform:

First step would be to install PECL

 sudo apt-get install autoconf zlib1g-dev php-dev php-pear


After successful installation of PECL, you have to install grpc with help of pecl

 sudo pecl install grpc

Be patient, Above step will take much time to install

After successful install of grpc, you have to enable grpc extension in php.in file by adding the below line

 extension=grpc.so

You can add in two php.ini files. One would be inside cli folderand another would be inside  apache2 folder 

ex: /etc/phpX.X/cli/php.ini and /etc/phpX.X/apache2/php.ini 
here X.X is the version you want to install (ex: 7.3, so /etc/php7.3/apache2/php.ini )
Note: ini file location would be different for different users depend where it was installed

After adding in both files, restart your apache server 
 /etc/init.d/apache2 restart

Thats done! Now your linux pc apache has been successully got grpc extension.

Now you easily install grpc dependency in your PHP project folder through composer

 composer require "grpc/grpc:^v1.27.0"

Post a Comment

9 Comments

  1. grpc extension is not loading.
    Here I got:
    PHP Warning: PHP Startup: Unable to load dynamic library 'grpc.so' (tried: /usr/lib/php/20170718/grpc.so (/usr/lib/php/20170718/grpc.so: undefined symbol: zend_string_init_interned), /usr/lib/php/20170718/grpc.so.so (/usr/lib/php/20170718/grpc.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning: PHP Startup: Unable to load dynamic library 'protobuf.so' (tried: /usr/lib/php/20170718/protobuf.so (/usr/lib/php/20170718/protobuf.so: undefined symbol: zend_string_init_interned), /usr/lib/php/20170718/protobuf.so.so (/usr/lib/php/20170718/protobuf.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning: PHP Startup: Unable to load dynamic library 'grpc.so' (tried: /usr/lib/php/20170718/grpc.so (/usr/lib/php/20170718/grpc.so: undefined symbol: zend_string_init_interned), /usr/lib/php/20170718/grpc.so.so (/usr/lib/php/20170718/grpc.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning: PHP Startup: Unable to load dynamic library 'protobuf.so' (tried: /usr/lib/php/20170718/protobuf.so (/usr/lib/php/20170718/protobuf.so: undefined symbol: zend_string_init_interned), /usr/lib/php/20170718/protobuf.so.so (/usr/lib/php/20170718/protobuf.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

    ReplyDelete
    Replies
    1. This line "PHP Warning: PHP Startup: Unable to load dynamic library 'grpc.so' ( "
      shows, grpc extension is not properly installed. please follow the steps mentioned in chapter properly

      Delete
    2. The reason may be different. May be we have multiple extensions folder for php.

      Delete
    3. Yup, you are right. This can be the one case. Having different php installed in a system.

      Delete
  2. Replies
    1. Hi,

      This issue can happen of multiple PHP version are installed. Check of you are using the correct version.

      Please follow us for new posts.

      Delete
  3. Hi, noticed that PECL have stopped giving .dll file from grpc v1.43.0, is there any other source when I can get compiler gRPC for php v8.2. or ^

    ReplyDelete
    Replies
    1. Hi I can see last release date is 2023-06-16 1.56.0 version. So I think they are updating constantly.

      Delete