public function getEnvVar($variable, $sshUrl, $refresh = false, $ttl = 3600)
    {
        $varName = $this->config->get('service.env_prefix') . $variable;
        $cacheKey = 'env-' . $sshUrl . '-' . $varName;
        $cached = $this->cache->fetch($cacheKey);
        if ($refresh || $cached === false) {
            $args = ['ssh'];
            $args = array_merge($args, $this->ssh->getSshArgs());
            $args[] = $sshUrl;
            $args[] = 'echo $' . $varName;
            $cached = $this->shellHelper->execute($args, null, true);
            $this->cache->save($cacheKey, $cached, $ttl);
        }

        return $cached ?: '';
    }
public function getEnvVar($variable, $sshUrl, $refresh = false, $ttl = 3600)
    {
        $varName = $this->config->get('service.env_prefix') . $variable;
        $cacheKey = 'env-' . $sshUrl . '-' . $varName;
        $cached = $this->cache->fetch($cacheKey);
        if ($refresh || $cached === false) {
            $args = ['ssh'];
            $args = array_merge($args, $this->ssh->getSshArgs());
            $args[] = $sshUrl;
            $args[] = 'echo $' . $varName;
            $cached = $this->shellHelper->execute($args, null, true);
            $this->cache->save($cacheKey, $cached, $ttl);
        }

        return $cached ?: '';
    }
public function getEnvVar ( $ variable , $ sshUrl , $ refresh = false , $ ttl = 3600 ) { $ varName = $ this -> config -> get ( 'service.env_prefix' ) . $ variable ; $ cacheKey = 'env-' . $ sshUrl . '-' . $ varName ; $ cached = $ this -> cache -> fetch ( $ cacheKey ) ; if ( $ refresh || $ cached === false ) { $ args = [ 'ssh' ] ; $ args = array_merge ( $ args , $ this -> ssh -> getSshArgs ( ) ) ; $ args [ ] = $ sshUrl ; $ args [ ] = 'echo $' . $ varName ; $ cached = $ this -> shellHelper -> execute ( $ args , null , true ) ; $ this -> cache -> save ( $ cacheKey , $ cached , $ ttl ) ; } return $ cached ? : '' ; }
Read an environment variable from a remote application.

@param string $variable The unprefixed name of the variable.
@param string $sshUrl   The SSH URL to the application.
@param bool   $refresh  Whether to refresh the cache.
@param int    $ttl      The cache lifetime of the result.

@throws \Symfony\Component\Process\Exception\RuntimeException
If the SSH command fails.

@return string The environment variable or an empty string.
Read an environment variable from a remote application .