Setup

In order to access services you have to create the client object. To do it, you will need to provide the following information:

  • The identity service URL (authUrl)

  • The region in which you want to operate (region)

  • The credentials of the user you want to authenticate: user, tokenId, cachedToken or application_credential

Only the authUrl is mandatory to create the client. But you will have to provide the region and user credentials to each service you create. So it is recommended to provide them when creating the client which would propagate these options to each service.

Authenticate

There are different ways to provide the authentication credentials. See the Tokens section for the full list of options. You should provide credentials to the OpenStack constructor as an array the same way you provide options to generateToken method of the Identity service.

By username

The most common way to authenticate is using the username and password of the user. You should also provide the Domain ID as usernames will not be unique across an entire OpenStack installation

<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
    'authUrl' => '{authUrl}',
    'region'  => '{region}',
    'user' => [
        'name'     => '{username}',
        'password' => '{password}',
        'domain'   => [
            'id' => '{domainId}'
        ]
    ]
]);

By user ID

<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
    'authUrl' => '{authUrl}',
    'region'  => '{region}',
    'user' => [
        'id'       => '{userId}',
        'password' => '{password}'
    ]
]);

By application credential ID

<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
    'authUrl'                => '{authUrl}',
    'region'                 => '{region}',
    'application_credential' => [
        'id'     => '{applicationCredentialId}',
        'secret' => '{secret}',
    ],
]);

By token ID

If you already have a valid token, you can use it to authenticate.

<?php

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
    'authUrl' => '{authUrl}',
    'region'  => '{region}',
    'tokenId' => '{tokenId}',
]);

Other options

For production environments it is recommended to decrease error reporting not to expose sensitive information. It can be done by setting the errorVerbosity key to 0 in the options array. It is set to 2 by default.

$openstack = new OpenStack\OpenStack([
    'errorVerbosity' => 0,
    // other options
]);