Open nevernet opened 7 years ago
Please follow this instruction to install protoc-gen-php. Please let me know if that doesn't work.
my steps as bleow:
git clone -b v1.0.0 https://github.com/grpc/grpc --depth=1
cd grpc
git checkout -b v1.0.0
cd examples/php
composer install
composer outputs:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing stanley-cheung/protobuf-php (dev-master e15c884)
Cloning e15c8846bd90a2638a2017e6b6663cd195885300 from cache
- Installing grpc/grpc (v0.15.2)
Downloading: 100%
Writing lock file
Generating autoload files
attention protobuf-php version is: dev-master
next step:
cd vendor/stanley-cheung/protobuf-php
sudo gem install rake ronn
//outputs
//Successfully installed rake-11.3.0
//Parsing documentation for rake-11.3.0
//Successfully installed ronn-0.7.3
//Parsing documentation for ronn-0.7.3
//2 gems installed
rake pear:package version=1.0
sudo pear install Protobuf-1.0.tgz
//outputs
//downloading Console_CommandLine-1.2.2.tgz ...
//Starting to download Console_CommandLine-1.2.2.tgz (40,705 bytes)
//...........done: 40,705 bytes
//install ok: channel://pear.php.net/Console_CommandLine-1.2.2
//install ok: channel://__uri/Protobuf-1.0
//back to route_guide folder:
cd ../../../route_guide
//current folder is:
//github/grpc/examples/php/route_guide
protoc-gen-php -i . -o . ./route_guide.proto
//outputs
//zsh: command not found: protoc-gen-php
// (because there is no global command which named protoc-gen-php)
@stanley-cheung please above comment thank you
additional debugs
cd $(pear config-get php_dir)
pwd
/usr/local/Cellar/php56/5.6.27_4/lib/php
the DrSlump was installed in this folder
total 200
drwxrwxr-x 24 qinxin admin 816B 10 26 09:35 .
drwxr-xr-x 3 qinxin admin 102B 10 19 13:10 ..
drwxrwxr-x 7 qinxin admin 238B 10 19 13:10 .channels
-r--r--r-- 1 qinxin admin 2.7K 10 26 13:02 .depdb
-r--r--r-- 1 qinxin admin 0B 10 26 13:02 .depdblock
-r--r--r-- 1 qinxin admin 18K 10 26 13:02 .filemap
-r--r--r-- 1 qinxin admin 0B 10 26 13:02 .lock
drwxrwxr-x 10 qinxin admin 340B 10 26 13:02 .registry
drwxrwxr-x 3 qinxin admin 102B 10 19 13:10 Archive
drwxrwxr-x 5 qinxin admin 170B 10 26 13:02 Console
drwxr-xr-x 4 qinxin admin 136B 10 26 13:02 DrSlump
drwxrwxr-x 3 qinxin admin 102B 10 19 13:10 OS
drwxrwxr-x 31 qinxin admin 1.0K 10 19 13:10 PEAR
-r--r--r-- 1 qinxin admin 35K 10 19 13:10 PEAR.php
drwxrwxr-x 4 qinxin admin 136B 10 19 13:10 Structures
-r--r--r-- 1 qinxin admin 20K 10 19 13:10 System.php
drwxrwxr-x 3 qinxin admin 102B 10 19 13:10 XML
drwxrwxr-x 13 qinxin admin 442B 10 19 13:10 build
drwxrwxr-x 4 qinxin admin 136B 10 25 16:57 data
drwxrwxr-x 9 qinxin admin 306B 10 26 09:35 doc
drwxr-xr-x 3 qinxin admin 102B 10 19 13:38 extensions
-r--r--r-- 1 qinxin admin 15K 10 19 13:10 pearcmd.php
-r--r--r-- 1 qinxin admin 1.0K 10 19 13:10 peclcmd.php
drwxrwxr-x 7 qinxin admin 238B 10 25 16:57 test
so have to use command from vendor folder:
./vendor/bin/protoc-gen-php.php -i . -o . helloworld.proto
// If on windows and no arguments were given
} else if ($_SERVER['argc'] < 2) {
$stdin = fread(STDIN, 1024 * 1024);
}
// If no input was given we launch protoc from here
if (0 === strlen($stdin)) {
if ($isWin) {
$pluginExecutable .= '.bat';
}
self::runProtoc($pluginExecutable);
exit(0);
}
cause the $_SERVER['argc'] is greater than 2, so the $stdin is empty always,
so it will always execute self::runProtoc($pluginExecutable);
then exit(0)
see the code:
(file is: \DrSlump\Protobuf\Compiler\Cli.php
when i run command
./vendor/bin/protoc-gen-php.php -i . -o . helloworld.proto
and the $_SERVER['argc'] is always more than 2 see details as below:so it will always execute
runProtoc($pluginExecutable);
, but not generate the grpc php codeplease advice how to use it.
thank you