PHP code example of google / cloud-service-directory

1. Go to this page and download the library: Download google/cloud-service-directory 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/ */

    

google / cloud-service-directory example snippets




use Google\Cloud\ServiceDirectory\V1\RegistrationServiceClient;
use Google\Cloud\ServiceDirectory\V1\Service;

$client = new RegistrationServiceClient();

$projectId = '[YOUR_PROJECT_ID]';
$location = 'us-central1';
$serviceId = '[YOUR_SERVICE_ID]';
$namespace = '[YOUR_NAMESPACE]';

$service = $client->createService(
    RegistrationServiceClient::namespaceName(
        $projectId,
        $location,
        $namespace
    ),
    $serviceId,
    new Service()
);

printf(
    'Created service: %s' . PHP_EOL,
    $service->getName()
);