Download the PHP package artpetrov/selectel-cloud-storage without Composer
On this page you can find all versions of the php package artpetrov/selectel-cloud-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package selectel-cloud-storage
artpetrov/selectel-cloud-storage
[![Latest Version on Packagist][ico-version]][link-packagist] ![Software License][ico-license]
Unofficial PHP SDK for Selectel Cloud Storage API.
Requirements
This package requires PHP 7.*.
Installation
You can install the package via composer:
Usage
Initialize Storage
CloudStorage
ArtPetrov\Selectel\CloudStorage\CloudStorage
class allows you to access and create containers.
Containers Collection
CloudStorage::containers
method returns instance of ArtPetrov\Selectel\CloudStorage\Collections\Collection
class with retrieved containers objects. This collection object implements ArrayAccess
, Countable
, Iterator
and JsonSerializable
interfaces, what makes you able to do these things:
Container Instance
Container that you've retrieved from Containers Collection is an ArtPetrov\Selectel\CloudStorage\Container
instance object which implements Countable
and JsonSerializable
interfaces.
Fluent Files Loader
You can use instance of ArtPetrov\Selectel\CloudStorage\FluentFilesLoader
class to retrieve files from container.
Fluent loader returns Collection
of file arrays or Collection
of File
objects.
This instance is accesible from $container->files()
method and allows you to do following things:
If you need to create FluentFilesLoader
instance without Container
instance, use following code:
File Uploads
Container
class provides uploadFromString
method to upload file contents and uploadFromStream
method to upload file from stream.
Both methods accepts array $params
as third optional argument.
Also, uploadFromString
method accepts 4th argument bool $verifyChecksum
. If true, Selectel will perform MD5 checksum comparison and if something went wrong during upload process, it won't accept file and exception will be thrown. This option is enabled by default for uploadFromString
method.
File Instance
When you retrieve collection of files via Contrainer::files
method you get Collection
of file arrays:
But when you're using Container::files()->find
method, you receive instance of ArtPetrov\Selectel\CloudStorage\File
class that implements JsonSerializable
interface. With this object you can perform operations such as renaming, copying and deleting file.
If you need to transform file from array to File
instance you can use Container::getFileFromArray
method:
Also, you can use Container::getFilesCollectionFromArrays
method to convert files Collection
or array of file arrays to Collection
of File
instances:
Fluent loader (FluentFilesLoader
) can also return Collection
of file objects by calling asFileObjects
method before get
method (see Fluent Files Loader section).
Warning: converting a lot of files to File
instances may result in performance loss.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.