You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,11 @@ You can see in the first example that the constant `Rackspace::US_IDENTITY_ENDPO
55
55
Rackspace's identity endpoint (`https://identity.api.rackspacecloud.com/v2.0/`). Another difference is that Rackspace
56
56
uses API key for authentication, whereas OpenStack uses a generic password.
57
57
58
+
#### 1.2 Logger injection
59
+
As the `Rackspace` client extends the `OpenStack` client, they both support passing `$options` as an array via the constructor's third parameter. The options are passed as a config to the `Guzzle` client, but also allow to inject your own `Logger`.
60
+
61
+
Prerequisities and usage example can be found in [the Clients userguide](/docs/userguide/Clients.md#12-logger-injection)
62
+
58
63
### 2. Pick what service you want to use
59
64
60
65
In this case, we want to use the Compute (Nova) service:
Copy file name to clipboardExpand all lines: docs/userguide/Clients.md
+28-6Lines changed: 28 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Users have access to two types of client: `OpenCloud\OpenStack` and `OpenCloud\R
11
11
3.`OpenCloud\OpenStack`
12
12
4.`OpenCloud\Rackspace`
13
13
14
-
## Initializing a client
14
+
## 1. Initializing a client
15
15
16
16
### Rackspace
17
17
@@ -44,7 +44,29 @@ $client = new OpenStack('http://identity.my-openstack.com/v2.0', array(
44
44
));
45
45
```
46
46
47
-
## Authentication
47
+
#### 1.2 Logger injection
48
+
As the `Rackspace` client extends the `OpenStack` client, they both support passing `$options` as an array via the constructor's third parameter. The options are passed as a config to the `Guzzle` client, but also allow to inject your own `Logger`.
49
+
50
+
Your logger should implement the `Psr\Log\LoggerInterface`[as defined in PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md). Example of a compatible logger is [`Monolog`](https://github.com/Seldaek/monolog). When the client does create a service, it will inject the logger if one is available.
51
+
52
+
To inject a `LoggerInterface` compatible logger into a new `Client`:
53
+
54
+
```php
55
+
use Monolog\Logger;
56
+
use OpenCloud\OpenStack;
57
+
58
+
// create a log channel
59
+
$log = new Logger('name');
60
+
61
+
$client = new OpenStack('http://identity.my-openstack.com/v2.0', array(
62
+
'username' => 'foo',
63
+
'password' => 'bar'
64
+
), array(
65
+
'logger' => $log,
66
+
));
67
+
```
68
+
69
+
## 2. Authentication
48
70
49
71
The Client does not automatically authenticate against the API on object creation - it waits for an API call. When this happens, it checks whether the current "token" has expired, and (re-)authenticates if necessary.
50
72
@@ -56,7 +78,7 @@ $client->authenticate();
56
78
57
79
If the credentials are incorrect, a `401` error will be returned. If credentials are correct, a `200` status is returned with your Service Catalog.
58
80
59
-
## Service Catalog
81
+
## 3. Service Catalog
60
82
61
83
The Service Catalog is returned on successful authentication, and is composed of all the different API services available to the current tenant. All of this functionality is encapsulated in the `Catalog` object, which allows you greater control and interactivity.
62
84
@@ -86,14 +108,14 @@ foreach ($catalog->getItems() as $catalogItem) {
86
108
87
109
As you can see, you have access to each Service's name, type and list of endpoints. Each endpoint provides access to the specific region, along with its public and private endpoint URLs.
For a full list of functionality provided by Guzzle, please consult the [official documentation](http://docs.guzzlephp.org/en/latest/http-client/client.html).
121
+
For a full list of functionality provided by Guzzle, please consult the [official documentation](http://docs.guzzlephp.org/en/latest/http-client/client.html).
0 commit comments