From 72642455a1d10656de719409806e88b6cc635758 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Mon, 31 Aug 2015 14:05:47 -0700 Subject: php: change routeguide package name --- examples/php/route_guide/README.md | 20 ++-- examples/php/route_guide/route_guide.php | 128 ++++++++++++------------ examples/php/route_guide/route_guide.proto | 2 +- examples/php/route_guide/route_guide_client.php | 16 +-- 4 files changed, 83 insertions(+), 83 deletions(-) (limited to 'examples/php') diff --git a/examples/php/route_guide/README.md b/examples/php/route_guide/README.md index 258158d5d1..00610ffb09 100644 --- a/examples/php/route_guide/README.md +++ b/examples/php/route_guide/README.md @@ -153,7 +153,7 @@ require dirname(__FILE__) . '/route_guide.php'; The file contains: - All the protocol buffer code to populate, serialize, and retrieve our request and response message types. -- A class called `examples\RouteGuideClient` that lets clients call the methods defined in the `RouteGuide` service. +- A class called `routeguide\RouteGuideClient` that lets clients call the methods defined in the `RouteGuide` service. @@ -166,7 +166,7 @@ In this section, we'll look at creating a PHP client for our `RouteGuide` servic To call service methods, we first need to create a client object, an instance of the generated `RouteGuideClient` class. The constructor of the class expects the server address and port we want to connect to: ```php -$client = new examples\RouteGuideClient(new Grpc\BaseStub('localhost:50051', [])); +$client = new routeguide\RouteGuideClient(new Grpc\BaseStub('localhost:50051', [])); ``` ### Calling service methods @@ -178,13 +178,13 @@ Now let's look at how we call our service methods. Calling the simple RPC `GetFeature` is nearly as straightforward as calling a local asynchronous method. ```php - $point = new examples\Point(); + $point = new routeguide\Point(); $point->setLatitude(409146138); $point->setLongitude(-746188906); list($feature, $status) = $client->GetFeature($point)->wait(); ``` -As you can see, we create and populate a request object, i.e. an `examples\Point` object. Then, we call the method on the stub, passing it the request object. If there is no error, then we can read the response information from the server from our response object, i.e. an `examples\Feature` object. +As you can see, we create and populate a request object, i.e. an `routeguide\Point` object. Then, we call the method on the stub, passing it the request object. If there is no error, then we can read the response information from the server from our response object, i.e. an `routeguide\Feature` object. ```php print sprintf("Found %s \n at %f, %f\n", $feature->getName(), @@ -197,15 +197,15 @@ As you can see, we create and populate a request object, i.e. an `examples\Point Now let's look at our streaming methods. Here's where we call the server-side streaming method `ListFeatures`, which returns a stream of geographical `Feature`s: ```php - $lo_point = new examples\Point(); - $hi_point = new examples\Point(); + $lo_point = new routeguide\Point(); + $hi_point = new routeguide\Point(); $lo_point->setLatitude(400000000); $lo_point->setLongitude(-750000000); $hi_point->setLatitude(420000000); $hi_point->setLongitude(-730000000); - $rectangle = new examples\Rectangle(); + $rectangle = new routeguide\Rectangle(); $rectangle->setLo($lo_point); $rectangle->setHi($hi_point); @@ -219,12 +219,12 @@ Now let's look at our streaming methods. Here's where we call the server-side st The `$call->responses()` method call returns an iterator. When the server sends a response, a `$feature` object will be returned in the `foreach` loop, until the server indiciates that there will be no more responses to be sent. -The client-side streaming method `RecordRoute` is similar, except there we pass the method an iterator and get back a `examples\RouteSummary`. +The client-side streaming method `RecordRoute` is similar, except there we pass the method an iterator and get back a `routeguide\RouteSummary`. ```php $points_iter = function($db) { for ($i = 0; $i < $num_points; $i++) { - $point = new examples\Point(); + $point = new routeguide\Point(); $point->setLatitude($lat); $point->setLongitude($long); yield $point; @@ -245,7 +245,7 @@ To write messages from the client: ```php foreach ($notes as $n) { - $route_note = new examples\RouteNote(); + $route_note = new routerguide\RouteNote(); $call->write($route_note); } $call->writesDone(); diff --git a/examples/php/route_guide/route_guide.php b/examples/php/route_guide/route_guide.php index a836e03b55..634dfe01aa 100644 --- a/examples/php/route_guide/route_guide.php +++ b/examples/php/route_guide/route_guide.php @@ -3,7 +3,7 @@ // Source: route_guide.proto // Date: 2015-06-12 00:32:41 -namespace examples { +namespace routeguide { class Point extends \DrSlump\Protobuf\Message { @@ -19,7 +19,7 @@ namespace examples { public static function descriptor() { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'examples.Point'); + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Point'); // OPTIONAL INT32 latitude = 1 $f = new \DrSlump\Protobuf\Field(); @@ -58,7 +58,7 @@ namespace examples { /** * Clear value * - * @return \examples\Point + * @return \routeguide\Point */ public function clearLatitude(){ return $this->_clear(1); @@ -77,7 +77,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\Point + * @return \routeguide\Point */ public function setLatitude( $value){ return $this->_set(1, $value); @@ -95,7 +95,7 @@ namespace examples { /** * Clear value * - * @return \examples\Point + * @return \routeguide\Point */ public function clearLongitude(){ return $this->_clear(2); @@ -114,7 +114,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\Point + * @return \routeguide\Point */ public function setLongitude( $value){ return $this->_set(2, $value); @@ -122,14 +122,14 @@ namespace examples { } } -namespace examples { +namespace routeguide { class Rectangle extends \DrSlump\Protobuf\Message { - /** @var \examples\Point */ + /** @var \routeguide\Point */ public $lo = null; - /** @var \examples\Point */ + /** @var \routeguide\Point */ public $hi = null; @@ -138,7 +138,7 @@ namespace examples { public static function descriptor() { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'examples.Rectangle'); + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Rectangle'); // OPTIONAL MESSAGE lo = 1 $f = new \DrSlump\Protobuf\Field(); @@ -146,7 +146,7 @@ namespace examples { $f->name = "lo"; $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\examples\Point'; + $f->reference = '\routeguide\Point'; $descriptor->addField($f); // OPTIONAL MESSAGE hi = 2 @@ -155,7 +155,7 @@ namespace examples { $f->name = "hi"; $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\examples\Point'; + $f->reference = '\routeguide\Point'; $descriptor->addField($f); foreach (self::$__extensions as $cb) { @@ -177,7 +177,7 @@ namespace examples { /** * Clear value * - * @return \examples\Rectangle + * @return \routeguide\Rectangle */ public function clearLo(){ return $this->_clear(1); @@ -186,7 +186,7 @@ namespace examples { /** * Get value * - * @return \examples\Point + * @return \routeguide\Point */ public function getLo(){ return $this->_get(1); @@ -195,10 +195,10 @@ namespace examples { /** * Set value * - * @param \examples\Point $value - * @return \examples\Rectangle + * @param \routeguide\Point $value + * @return \routeguide\Rectangle */ - public function setLo(\examples\Point $value){ + public function setLo(\routeguide\Point $value){ return $this->_set(1, $value); } @@ -214,7 +214,7 @@ namespace examples { /** * Clear value * - * @return \examples\Rectangle + * @return \routeguide\Rectangle */ public function clearHi(){ return $this->_clear(2); @@ -223,7 +223,7 @@ namespace examples { /** * Get value * - * @return \examples\Point + * @return \routeguide\Point */ public function getHi(){ return $this->_get(2); @@ -232,23 +232,23 @@ namespace examples { /** * Set value * - * @param \examples\Point $value - * @return \examples\Rectangle + * @param \routeguide\Point $value + * @return \routeguide\Rectangle */ - public function setHi(\examples\Point $value){ + public function setHi(\routeguide\Point $value){ return $this->_set(2, $value); } } } -namespace examples { +namespace routeguide { class Feature extends \DrSlump\Protobuf\Message { /** @var string */ public $name = null; - /** @var \examples\Point */ + /** @var \routeguide\Point */ public $location = null; @@ -257,7 +257,7 @@ namespace examples { public static function descriptor() { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'examples.Feature'); + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.Feature'); // OPTIONAL STRING name = 1 $f = new \DrSlump\Protobuf\Field(); @@ -273,7 +273,7 @@ namespace examples { $f->name = "location"; $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\examples\Point'; + $f->reference = '\routeguide\Point'; $descriptor->addField($f); foreach (self::$__extensions as $cb) { @@ -295,7 +295,7 @@ namespace examples { /** * Clear value * - * @return \examples\Feature + * @return \routeguide\Feature */ public function clearName(){ return $this->_clear(1); @@ -314,7 +314,7 @@ namespace examples { * Set value * * @param string $value - * @return \examples\Feature + * @return \routeguide\Feature */ public function setName( $value){ return $this->_set(1, $value); @@ -332,7 +332,7 @@ namespace examples { /** * Clear value * - * @return \examples\Feature + * @return \routeguide\Feature */ public function clearLocation(){ return $this->_clear(2); @@ -341,7 +341,7 @@ namespace examples { /** * Get value * - * @return \examples\Point + * @return \routeguide\Point */ public function getLocation(){ return $this->_get(2); @@ -350,20 +350,20 @@ namespace examples { /** * Set value * - * @param \examples\Point $value - * @return \examples\Feature + * @param \routeguide\Point $value + * @return \routeguide\Feature */ - public function setLocation(\examples\Point $value){ + public function setLocation(\routeguide\Point $value){ return $this->_set(2, $value); } } } -namespace examples { +namespace routeguide { class RouteNote extends \DrSlump\Protobuf\Message { - /** @var \examples\Point */ + /** @var \routeguide\Point */ public $location = null; /** @var string */ @@ -375,7 +375,7 @@ namespace examples { public static function descriptor() { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'examples.RouteNote'); + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteNote'); // OPTIONAL MESSAGE location = 1 $f = new \DrSlump\Protobuf\Field(); @@ -383,7 +383,7 @@ namespace examples { $f->name = "location"; $f->type = \DrSlump\Protobuf::TYPE_MESSAGE; $f->rule = \DrSlump\Protobuf::RULE_OPTIONAL; - $f->reference = '\examples\Point'; + $f->reference = '\routeguide\Point'; $descriptor->addField($f); // OPTIONAL STRING message = 2 @@ -413,7 +413,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteNote + * @return \routeguide\RouteNote */ public function clearLocation(){ return $this->_clear(1); @@ -422,7 +422,7 @@ namespace examples { /** * Get value * - * @return \examples\Point + * @return \routeguide\Point */ public function getLocation(){ return $this->_get(1); @@ -431,10 +431,10 @@ namespace examples { /** * Set value * - * @param \examples\Point $value - * @return \examples\RouteNote + * @param \routeguide\Point $value + * @return \routeguide\RouteNote */ - public function setLocation(\examples\Point $value){ + public function setLocation(\routeguide\Point $value){ return $this->_set(1, $value); } @@ -450,7 +450,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteNote + * @return \routeguide\RouteNote */ public function clearMessage(){ return $this->_clear(2); @@ -469,7 +469,7 @@ namespace examples { * Set value * * @param string $value - * @return \examples\RouteNote + * @return \routeguide\RouteNote */ public function setMessage( $value){ return $this->_set(2, $value); @@ -477,7 +477,7 @@ namespace examples { } } -namespace examples { +namespace routeguide { class RouteSummary extends \DrSlump\Protobuf\Message { @@ -499,7 +499,7 @@ namespace examples { public static function descriptor() { - $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'examples.RouteSummary'); + $descriptor = new \DrSlump\Protobuf\Descriptor(__CLASS__, 'routeguide.RouteSummary'); // OPTIONAL INT32 point_count = 1 $f = new \DrSlump\Protobuf\Field(); @@ -556,7 +556,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function clearPointCount(){ return $this->_clear(1); @@ -575,7 +575,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function setPointCount( $value){ return $this->_set(1, $value); @@ -593,7 +593,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function clearFeatureCount(){ return $this->_clear(2); @@ -612,7 +612,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function setFeatureCount( $value){ return $this->_set(2, $value); @@ -630,7 +630,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function clearDistance(){ return $this->_clear(3); @@ -649,7 +649,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function setDistance( $value){ return $this->_set(3, $value); @@ -667,7 +667,7 @@ namespace examples { /** * Clear value * - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function clearElapsedTime(){ return $this->_clear(4); @@ -686,7 +686,7 @@ namespace examples { * Set value * * @param int $value - * @return \examples\RouteSummary + * @return \routeguide\RouteSummary */ public function setElapsedTime( $value){ return $this->_set(4, $value); @@ -694,7 +694,7 @@ namespace examples { } } -namespace examples { +namespace routeguide { class RouteGuideClient{ @@ -704,28 +704,28 @@ namespace examples { $this->rpc_impl = $rpc_impl; } /** - * @param examples\Point $input + * @param routeguide\Point $input */ - public function GetFeature(\examples\Point $argument, $metadata = array()) { - return $this->rpc_impl->_simpleRequest('/examples.RouteGuide/GetFeature', $argument, '\examples\Feature::deserialize', $metadata); + public function GetFeature(\routeguide\Point $argument, $metadata = array()) { + return $this->rpc_impl->_simpleRequest('/routeguide.RouteGuide/GetFeature', $argument, '\routeguide\Feature::deserialize', $metadata); } /** - * @param examples\Rectangle $input + * @param routeguide\Rectangle $input */ public function ListFeatures($argument, $metadata = array()) { - return $this->rpc_impl->_serverStreamRequest('/examples.RouteGuide/ListFeatures', $argument, '\examples\Feature::deserialize', $metadata); + return $this->rpc_impl->_serverStreamRequest('/routeguide.RouteGuide/ListFeatures', $argument, '\routeguide\Feature::deserialize', $metadata); } /** - * @param examples\Point $input + * @param routeguide\Point $input */ public function RecordRoute($arguments, $metadata = array()) { - return $this->rpc_impl->_clientStreamRequest('/examples.RouteGuide/RecordRoute', $arguments, '\examples\RouteSummary::deserialize', $metadata); + return $this->rpc_impl->_clientStreamRequest('/routeguide.RouteGuide/RecordRoute', $arguments, '\routeguide\RouteSummary::deserialize', $metadata); } /** - * @param examples\RouteNote $input + * @param routeguide\RouteNote $input */ public function RouteChat($metadata = array()) { - return $this->rpc_impl->_bidiRequest('/examples.RouteGuide/RouteChat', '\examples\RouteNote::deserialize', $metadata); + return $this->rpc_impl->_bidiRequest('/routeguide.RouteGuide/RouteChat', '\routeguide\RouteNote::deserialize', $metadata); } } } diff --git a/examples/php/route_guide/route_guide.proto b/examples/php/route_guide/route_guide.proto index 0947184dbb..d50f8a5169 100644 --- a/examples/php/route_guide/route_guide.proto +++ b/examples/php/route_guide/route_guide.proto @@ -31,7 +31,7 @@ syntax = "proto2"; option java_package = "io.grpc.examples"; -package examples; +package routeguide; // Interface exported by the server. service RouteGuide { diff --git a/examples/php/route_guide/route_guide_client.php b/examples/php/route_guide/route_guide_client.php index 6d9ae58b66..d21a080995 100644 --- a/examples/php/route_guide/route_guide_client.php +++ b/examples/php/route_guide/route_guide_client.php @@ -37,7 +37,7 @@ require dirname(__FILE__) . '/route_guide.php'; define('COORD_FACTOR', 1e7); -$client = new examples\RouteGuideClient( +$client = new routeguide\RouteGuideClient( new Grpc\BaseStub('localhost:50051', [])); function printFeature($feature) { @@ -60,7 +60,7 @@ function runGetFeature() { print "Running GetFeature...\n"; global $client; - $point = new examples\Point(); + $point = new routeguide\Point(); $points = array( array(409146138, -746188906), array(0, 0), @@ -84,15 +84,15 @@ function runListFeatures() { print "Running ListFeatures...\n"; global $client; - $lo_point = new examples\Point(); - $hi_point = new examples\Point(); + $lo_point = new routeguide\Point(); + $hi_point = new routeguide\Point(); $lo_point->setLatitude(400000000); $lo_point->setLongitude(-750000000); $hi_point->setLatitude(420000000); $hi_point->setLongitude(-730000000); - $rectangle = new examples\Rectangle(); + $rectangle = new routeguide\Rectangle(); $rectangle->setLo($lo_point); $rectangle->setHi($hi_point); @@ -118,7 +118,7 @@ function runRecordRoute() { $num_points_in_db = count($db); $num_points = 10; for ($i = 0; $i < $num_points; $i++) { - $point = new examples\Point(); + $point = new routeguide\Point(); $index = rand(0, $num_points_in_db - 1); $lat = $db[$index]['location']['latitude']; $long = $db[$index]['location']['longitude']; @@ -163,11 +163,11 @@ function runRouteChat() { ); foreach ($notes as $n) { - $point = new examples\Point(); + $point = new routeguide\Point(); $point->setLatitude($lat = $n[0]); $point->setLongitude($long = $n[1]); - $route_note = new examples\RouteNote(); + $route_note = new routeguide\RouteNote(); $route_note->setLocation($point); $route_note->setMessage($message = $n[2]); -- cgit v1.2.3