/yii2-openstack

Openstack / swift client for Yii2 Framework

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Stable Version Untable Version License Total Downloads Build Status

yii2-openstack

Openstack / swift client for Yii2 Framework

Installation

Install with composer:

composer require raoptimus/yii2-openstack

Usage samples

Configuration

return [
    //....
    'components' => 
        'swift' => [
            'class' => raoptimus\openstack\Connection::class,
            'authUrl' => 'https://somedomain.com:5000/v2.0',
            'username' => '',
            'apiKey' => '',
            'tenant' => '',
            'domain' => '',
            'domainId' => '',
        ],
];
$swift = new raoptimus\openstack\Connection(
    [
        'class' => raoptimus\openstack\Connection::class,
        'authUrl' => 'https://somedomain.com:5000/v2.0',
        'username' => '',
        'apiKey' => '',
        'tenant' => '',
        'domain' => '',
        'domainId' => '',
    ]
);
$container = $swift->getContainer('name of container');

Use connection

$swift = \Yii::$app->get('swift');
$container = $swift->getContainer('name of container');

Push file to swift storage

$container->pushObject($source, $target);

Pull file from swift storage

$container->pullObject($source, $target);

Get stat of file from swift storage

$container->getObject($filename);

Exists file in swift storage

$container->existsObject($filename);

Delete file from swift storage

$container->deleteObject($filename);