Download the PHP package webiny/storage without Composer

On this page you can find all versions of the php package webiny/storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package storage

Storage Component

Storage Component is a storage abstraction layer that simplifies the way you work with files and directories.

Install the component

The best way to install the component is using Composer.

For additional versions of the package, visit the Packagist page.

Usage

You will need to use storage drivers to access different storage providers like local disk, Amazon, Rackspace, etc.

Webiny Framework provides LocalStorageDriver and S3StorageDriver but using a set of built-in interfaces will help you to develop a new driver in no time.

The following driver interfaces are available:

Configuring a storage service

The recommended way of using a storage is by defining a storage service. Here is an example of defining a service using LocalStorageDriver and S3StorageDriver: NOTE: you can use DIR to have your file paths built dynamically. DIR will be replaced with the directory path containing current config file.

(This is just one way of defining a service. For detailed documentation on defining a service refer to ServiceManager component.)

Using your new storage

To make use of local storage easier and more flexible, there are 2 classes: \Webiny\Component\Storage\File\File and \Webiny\Component\Storage\Directory\Directory. These 2 classes serve as wrappers so you never need to make calls to storage directly. Besides, they contain common methods you will need to perform actions on files and directories.

Let's take a look at how you would store a new file:

After calling setContents($contents) the contents is written to the storage immediately and a bool is returned.

Working with directories

Sometimes you need to read the whole directory, filter files by name, extension, etc. There is a special interface for this type of manipulation, \Webiny\Component\Storage\Directory\DirectoryInterface.

Since not all storage engines support directories, there is no generic implementation of this interface. There is, however, an implementation in form of Directory which works nicely with local file storage. There are 2 modes of reading a directory: recursive and non-recursive.

Reading a directory (non-recursive mode)

NOTE: directory files are not being fetched from storage until you actually use the object.

Filtering files (recursive mode)

NOTE: calling filter() does not change the original Directory object, but creates a new Directory object with filtered result, so once you've read the root directory you can filter it using any condition as many times as you need:

Deleting a directory

Deleting a directory (this is done recursively) is as simple as:

Storage events

There are 3 types of events fired when certain actions are performed on a File:

All 3 events pass an instance of \Webiny\Component\Storage\StorageEvent to their event handlers. Once your handler gets executed, you can access the file objects using $event->getFile() method.

StorageEvent::FILE_RENAMED event also assigns a special property called oldKey to the event object, which holds the value of file key before renaming (this will help you update your database records, etc.):

Resources

To run unit tests, you need to use the following command:

$ cd path/to/Webiny/Component/Storage/
$ composer.phar install
$ phpunit

All versions of storage with dependencies

PHP Build Version
Package Version
Requires php Version ^7
webiny/std-lib Version ~1.6
webiny/config Version ~1.6
webiny/service-manager Version ~1.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webiny/storage contains the following files

Loading the files please wait ....