protoc-gen-php
- protoc compiler plugin
protoc-gen-php
[-v
] [-o
directory] [-i
directory] file...
protoc-gen-php is a Google's Protocol Buffers compiler plugin
for the protoc
tool. It generates PHP classes compatible with
Protobuf for PHP from .proto files.
protoc-gen-php is written in PHP using features first found on PHP 5.3. It also requires the Console_CommandLine package from Pear.
Additionally you'll also need to have a working copy of Google Protocol Buffers's protoc command, version 2.3 or above, available on your path.
The command accepts the following command-line options (switches).
-v
, --verbose
:
Enables verbose mode. Additional information will be printed when
processing the files.
-h
, --help
:
Prints the usage help message and quits.
-i
directory, --include
=directory:
Tells the protoc compiler to look into that directory when resolving
import statements. Note that you can use this switch more than once
to configure multiple directories.
-o
directory, --out
=directory:
Tells the protoc compiler to create generated files in the given
directory. If not set it will create the files in the working
directory.
--protoc
=path to protoc binary:
If you don't happen to have the protoc
binary in your path, you can
use this option to indicate a path to it.
--skip-imported
Flags the compiler to only generate source code for the proto file
explicitely given on the command line. This means that imported files
will not be generated when using this option.
--comments
Parses the .proto files looking for multiline comments (/ ... /) to
include them in the generated files.
-Ddefine
, -Ddefine
=value:
Defines an option (defaults to true if no value given) to pass to
the generator. See protobuf-php(5) for supported options, noting that
the php.
prefix shall not be used here.
Generate a PHP file from a proto file:
$ protoc-gen-php tutorial.proto
Generate PHP files in the "build" directory for each proto file found the "protos" directory:
$ protoc-gen-php -o build protos/*.proto
Generate a PHP file from a proto file using imports from an include path:
$ protoc-gen-php -i ./protos protos/tutorial.proto
Generate a PHP file with a custom extension
$ protoc-gen-php -Dsuffix=pb.php tutorial.proto
Please report bugs using GitHub's issue tracker at http://github.com/drslump/protobuf-php/issues
Protobuf for PHP is Copyright (C) 2011 Ivan -DrSlump- Montes http://pollinimini.net
protobuf-php(3), protobuf-php(5), http://github.com/drslump/protobuf-php