Installing gRPC for localhost

9,998

Solution 1

With the help of this link.. I found that these steps will activate gRPC

  1. From PECL site (or windows.php.net which has the exact same files) .. choose DLL of the latest stable release enter image description here

  2. According to the PHP version you have :

    • For XAMPP with PHP > 7.2.15 .. choose Thread Safe (TS) x64

    • For older XAMPP .. choose Thread Safe (TS) x86

  3. Download the ZIP file then extract its contents

  4. Copy the php_grpc.dll file to the extensions folder in XAMPP (you can find the path in php.ini) .. in my case it was extension_dir="C:\xampp\php\ext"
  5. Enable the extension in your php.ini file :

    • For PHP version 7.2 and up .. add extension=grpc

    • For older PHP .. add extension=php_grpc.dll

  6. Restart XAMPP and the extension will be activated as showed in phpinfo()

enter image description here

Solution 2

I would like to add answer for 7.4.4 PHP Version,

I downloaded php_grpc-1.27.0-7.4-ts-vc15-x64.zip from this link https://windows.php.net/downloads/pecl/releases/grpc/1.27.0/

Then I copied pasted php_grpc.dll to C:\xampp\php\ext folder

In next step I opened php.ini under Dynamic extentions added extension=grpc

And then restarted and it was working fine.

Solution 3

Windows 10 | PHP 7.1

I tried to debug this for 4 hours and could not find the right solution. I later on realized that besides the grpc extension, there were some other extensions also like oci which threw the same error when I tried to uncomment those (while keeping grpc commented) and running any php command like php --ini

On some other forum I read that a user had to manually install PHP using windows installer and then install DLL. I thought I'll try that but I could not find an MSI so I downloaded the latest PHP zip installer from https://windows.php.net/download/ I chose the x64 version for php 7.1.

Please note that I did not install this downloaded PHP but I noticed it had a php7.dll I had used dependency walker from http://www.dependencywalker.com/ to check the dependencies of the php_grpc.dll and found php7.dll as a dependency.

So what I did was to copy both PHP7.dll and php_grpc.dll to system32 and then I tried to install that DLL. I ran a command prompt as Admin and navigated to C:\windows\system32 and executed the command regsvr32 php_grpc.dll (Please note that this does not work without PHP7.dll being present in the same folder - or at least it did not work for me). Upon execution, I got a message that the DLL was loaded but entry point was not found. At this time when I executed php --ini again (I also had php_grpc.dll loaded to ext folder under the XAMPP php folder) I got a new error finally which said that the module being loaded was Non thread safe (NTS) whereas PHP was TS (Thread Safe). So I went to PECL, downloaded the TS version of the grpc plugin for PHP7.1 and pasted the dll file to both system32 and also the ext folder. I ran the regsvr32 /U php_grpc.dll command which uninstalls and reinstalls the DLL i believe (I am not sure if this step made any difference but I am mentioning it here because I had performed this step before calling php --ini)

After this, finally php --ini ran without any issues. I was able to use the composer command to successfully download the dependencies for cloud-firestore. It was a waste of 4 precious hours but I hope this helps someone else.

NOTE: Instead of downloading from PECL, I downloaded the grpc zip from https://windows.php.net/downloads/pecl/releases/grpc/

I don't know if this is different but it was the link mentioned on the installation site for Windows installation of PHP. Also someone else has that link here. I took the latest build which was 1.24.0 at the time of this post. And I chose the Thread Safe Version.

The reason I chose the thread safe version is because of the error that I received of version mismatch. You can also check your version by executing "php -i" in console which returns same info as phpinfo(); Copy and paste the output in some text editor and search for PHP Extension Build. below is what I saw

PHP Extension Build => API20160303,TS,VC14

Note, it is TS aka thread safe. So unlike other posts on the internet where folks downloaded non thread safe version of grpc, I downloaded threadsafe and it worked.

Solution 4

Please download grpc extension zip from here

https://windows.php.net/downloads/pecl/releases/grpc/1.10.0/

accorging to your php version (My PHP version is 7.2.6 and x86 architecture xampp) I downloaded php_grpc-1.10.0-7.2-ts-vc15-x86.zip

after downloading extract zip file copy php_grpc.dll in e.g C:\xampp\php\ext folder

open php.ini under Dynamic extentions add extension=grpc

restart your apache server for checking open up cmd and type php -m it will show you all the extension enabled.

Share:
9,998

Related videos on Youtube

MujtabaFR
Author by

MujtabaFR

Web & Mobile apps developer 👉 HTML, CSS, Javascript (React-Native), PHP, Objective-C, Swift, C# I also work as a doctor in my free time 😌

Updated on June 04, 2022

Comments

  • MujtabaFR
    MujtabaFR almost 2 years

    I'm working with PHP library of Google Cloud Firestore, it requires me to install and enable the gRPC extension.. I've read the guide which says

    Windows users can download and enable DLLs from PECL. Support for Windows is experimental

    In the PECL site I can see many links to tgz and DLL files but without any explanation of how to use or activate them in the XAMPP as a localhost

  • Frosty
    Frosty almost 6 years
    i know this is old , but I'm trying to do the same but i cant seem to find any php_grpc.dll files or anything can you give more info on what to do?
  • MujtabaFR
    MujtabaFR almost 6 years
    @Innervisions you can find the php_grpc.dll file in content of the ZIP you downloaded .. I've updated the answer to make it more clear
  • Frosty
    Frosty almost 6 years
    I did everything as you said and i still don't see it, i hate this extension so much...
  • Frosty
    Frosty almost 6 years
    do i need to download the other rar thats not the DLL and if i do where do i place it?
  • MujtabaFR
    MujtabaFR almost 6 years
    @innervisions no, it won't be useful, what is the link to the zip file you downloaded which should contain the DLL file ?
  • Frosty
    Frosty almost 6 years
    the 1.13.0 version non-thread safe but i tried all for the 7.2 php version none of them worked
  • MujtabaFR
    MujtabaFR almost 6 years
    @Innervisions I've uploaded the php_grpc.dll file for you.. so you can download it directly drive.google.com/file/d/1Kv2PZJu2fxD92vcXHOptwV_hmWKAnjhG/…
  • Frosty
    Frosty almost 6 years
    Doesn't work with that file. I followed all of your instructions , i just don't see the extension when i write check phpinfo() , when i try to install something with the console i get an error that it can't find grpc module I get this: PHP Warning: PHP Startup: Unable to load dynamic library 'php_grpc.dll' (tried: D:\Xamp\php\ext\php_grpc.dll (The specified module could not be found.), D:\Xamp\php\ext\php_php_grpc.dll.dll (The specified module could not be found.)) in Unknown on line 0
  • MujtabaFR
    MujtabaFR almost 6 years
    sorry about that.. check this link, hope it can solve the problem for you stackoverflow.com/questions/19772356/…
  • Latief Anwar
    Latief Anwar about 5 years
    don't forget, wamp, xampp have 2 version php.ini file, we must add extension in all php.ini file, if not, it does not work while downloading cloud-firestore library via composer
  • Mike Poole
    Mike Poole almost 5 years
    This does not appear to be an answer. If it is an answer please could you reword is De Hams so it is clearly such. Thanks.
  • De Hams
    De Hams almost 5 years
    No this is a question, finally solve use the php_grpc.dll from this link windows.php.net/downloads/pecl/releases/grpc/1.10.0
  • ephraim lambarte
    ephraim lambarte about 4 years
    @DeHams Thank you, i downloaded the threadsafe x64 version and it worked for me
  • Ayaz Ali Shah
    Ayaz Ali Shah about 4 years
    This answer works for me, my php version is 7.2.11. I tried above accepted answer which was not working, i am not saying that one is wrong but this answered solved my problem.
  • John Henrique
    John Henrique over 3 years
    You comment help me, thanks. I was get NTS version...
  • tanay jha
    tanay jha about 3 years
    As instructed, I downloaded the php_grpc-1.37.0-7.3-ts-vc15-x64, unzipped and copied the .dll file into php/ext folder, added extension=php_grpc in the php.ini file, restarted the xampp and it worked fine. I am using PHP 7.3.9 on Windows 10 OS.
  • Yousof K.
    Yousof K. almost 3 years
    Helped me. Windows 10, XAMP with PHP 7.4