PHP code example of multilinguals / apollo-client

1. Go to this page and download the library: Download multilinguals/apollo-client 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/ */

    

multilinguals / apollo-client example snippets


#!/usr/bin/env php

ollo\Client\ApolloClient;

//specify address of apollo server
$server = getenv('CONFIG_SERVER'); // get server address from env

//specify your appid at apollo config server
$appid = getenv('APPID'); // get appid from env

//specify namespaces of appid at apollo config server
$namespaces = getenv('NAMESPACE'); // get namespaces from env
$namespaces = explode(',', $namespaces);

$apollo = new ApolloClient($server, $appid, $namespaces);

if ($clientIp = getenv('CLIENTIP')) {
    $apollo->setClientIp($clientIp);
}

ini_set('memory_limit','128M');
$pid = getmypid();
echo "start [$pid]\n";
$restart = true; //auto start if failed
do {
    $error = $apollo->start();
    if ($error) echo('error:'.$error."\n");
}while($error && $restart);