Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Last active May 12, 2021 19:19
Show Gist options
  • Select an option

  • Save Greg-Boggs/7c2f8a0be2e674ef375f29cb23f93e58 to your computer and use it in GitHub Desktop.

Select an option

Save Greg-Boggs/7c2f8a0be2e674ef375f29cb23f93e58 to your computer and use it in GitHub Desktop.
How to print a platformsh route for your environment in PHP
<?php
$projectId = getenv('PLATFORM_PROJECT');
// A JSON-encoded value.
$projectId = getenv('PLATFORM_PROJECT');
// A JSON-encoded value.
$routes = json_decode(base64_decode(getenv('PLATFORM_ROUTES')), TRUE);
foreach ($routes as $route => $details) {
echo $route;
continue;
}
// Or alternatively after composer require platformsh/config-reader
require __DIR__ . '/vendor/autoload.php';
use Platformsh\ConfigReader\Config;
$config = new Config();
$route = $config->getPrimaryRoute();
echo $route;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment