Defining a Server

Loading a Server profile

To load a content, simply provide the profile name to the get() static function from the helper class \Drupal\xtc\XtendedContent\API\XtcServer.

$content = \Drupal\xtc\XtendedContent\API\XtcServer::get('test_text');

Plugin definition

This is a Drupal 8 YAML plugin.

Yaml file

The profiles can be defined in a YAML file that follows this pattern: [module_name].xtc_servers.yml.

The plugin is defined in the Xtended Content (xtc) module: xtc/src/PluginManager/XtcServer/XtcServerPluginManager.php.


A Server profile definition looks like this:

  label: 'XTC Elastica'
  description: 'Elastica Server, for multiple environments.'
  type: 'elastica'
  env: 'prod'
      host: ''
      port: 9200
      host: ''
      port: 9200
      host: ''
      port: 9200

label (string) and description (string) are mandatory for any Drupal 8 plugin definition.

Server type type (string)

Available types provided by the XTC modules in the *.xtc_servers.yml files are:

  • Elastica elastica: used by XTC Elastica and XTC PHP ElasticSearch handlers
  • Guzzle guzzle: used by XTC Guzzle handler

Server active environment env (string)

Defines the active environment to be used by the Drupal instance. Environments are used to facilitate deployment between different environments.

Active environment can be overriden in the settings.local.php file:

$settings['xtc.serve_client']['xtc']['serve_client']['server']['xtc_elastica']['env'] = 'dev';

If 2 different environments need to be used on the same instance of Drupal, it means you should define 2 different server profiles.

Additional values

Depending on the Handler that need a Server definition, you might need to define additional values.

For example, XTC Elastica expects a Connection connection (array) to be defined, while XTC Guzzle API needs a Path path (array) and accepts Options options (array). In this case, Options are, transparently, the ones from the Guzzle API.

  label: 'Countries'
  description: ''
  type: 'guzzle'
  env: 'prod-int'
    verify: false
    timeout: 5
      tls: false
      server: ""
      port: 8001
      endpoint: "pays"
      tls: true
      server: ""
      port: 8011
      endpoint: "pays"
      tls: false
      server: ""
      port: 8001
      endpoint: "pays"
      tls: true
      server: ""
      port: 8011
      endpoint: "pays"


Server profiles are used by:

  • XTC PHP ElasticSearch
  • XTC Guzzle
  • XTC Elastica
  • XTC Search