PHP code example of ndunks / php-simple-protobuf

1. Go to this page and download the library: Download ndunks/php-simple-protobuf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ndunks / php-simple-protobuf example snippets

`
vendor\bin\compiler.php.bat --out=<out-dir> --file=<proto-file>
`
/ Class Simple compiled from simple.proto (find on test/proto)
$obj = new Simple();
$obj->setName('user');
$obj->setAddress('Indonesia');
$obj->setAge(25);
$obj->toArray(); // as PHP Array
$obj->toJson(); // as JSON formated string

git clone https://github.com/ndunks/php-simple-protobuf
cd php-simple-protobuf
composer dump-autoload

# if output directory not exist, you must create it manualy
mkdir result
# Compile it
php bin/compiler.php --out=result --file=test/proto/simple.proto