composer require php-opencloud/openstack ^3.0
<?php
require 'vendor/autoload.php';
// Don't forget the trailing slash
$client = new \GuzzleHttp\Client(['base_uri' => 'https://auth.cloud.ovh.net/v3/']);
$token = new \OpenStack\Identity\v3\Models\Token($client, new \OpenStack\Identity\v3\Api());
$token->create([
'user' => [
'name' => 'USERNAME',
'domain' => [
'name' => 'Default',
],
'password' => 'PASSWORD',
],
]);
// You should save the token for later use
file_put_contents('openstack.json', json_encode($token->export()));
<?php
require 'vendor/autoload.php';
$cachedToken = json_decode(file_get_contents('openstack.json'), true);
$openstack = new \OpenStack\OpenStack([
'authUrl' => 'https://auth.cloud.ovh.net/v3/',
'region' => 'REGION',
'tenantName' => 'TENANT',
'cachedToken' => $cachedToken,
]);
$service = $openstack->objectStoreV1();
$container = $service->getContainer('CONTAINER');
$container->createObject([
'name' => 'FILENAME',
'content' => 'CONTENT',
]);
Very useful ! Thanks, the doc is very poor and often outdated.