PHP code example of serato / sws-discovery

1. Go to this page and download the library: Download serato/sws-discovery 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/ */

    

serato / sws-discovery example snippets


use Serato\ServiceDiscovery\HostName;

# Create an instance providing and environment name and number
$hostNames = new HostName('production', 1);

# Use the `HostName::get` method to return the host name for a named application
echo $hostNames->get(HostName::IDENTITY);

# Use the `HostName::getAll` method to return an array of all hosts
print_r($hostNames->getAll());
bash
# Run the `php-build` service using the default PHP version (7.1) and remove the container after use.
docker-compose run --rm  php-build

# Provide an alternative PHP version via the PHP_VERSION environment variable.
PHP_VERSION=7.2 docker-compose run --rm  php-build