1. Go to this page and download the library: Download rasuvaeff/yii3-filestorage library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rasuvaeff / yii3-filestorage example snippets
// config/common/di/filestorage.php
use Psr\Http\Message\StreamFactoryInterface;
use Rasuvaeff\Yii3Filestorage\Repository\RepositoryInterface;
use Rasuvaeff\Yii3Filestorage\Store\FileSystem\FileSystemStore;
use Rasuvaeff\Yii3Filestorage\Store\StoreInterface;
use Rasuvaeff\Yii3Filestorage\Test\MemoryRepository;
return [
StoreInterface::class => static fn (StreamFactoryInterface $streams): StoreInterface
=> new FileSystemStore(
name: 'upload',
rootPath: '/app/runtime/upload',
streamFactory: $streams,
),
// Development only — every record is lost when the process ends.
RepositoryInterface::class => MemoryRepository::class,
];
use Rasuvaeff\Yii3Filestorage\StorageInterface;
use Rasuvaeff\Yii3Filestorage\Upload;
// From an HTTP upload.
$file = $storage->add(
Upload::fromUploadedFile($request->getUploadedFiles()['avatar'], $streamFactory),
groupName: 'avatars',
);
// From something your application generated — a rendered PDF, an export.
$file = $storage->add(
Upload::fromStream($pdfStream, 'invoice-2026-08.pdf', $streamFactory),
groupName: 'documents',
description: 'August invoice',
metadata: ['invoiceId' => 4711],
);
// From a path.
$file = $storage->add(Upload::fromPath('/tmp/import.csv', $streamFactory));
$file = $storage->find($id);
$stream = $storage->stream($file); // PSR-7, the default read path
$bytes = $storage->content($file); // capped; throws ContentTooLargeException
$there = $storage->exists($file); // are the bytes still physically there
$url = $storage->urlFor($file); // the one to call
$url = $storage->urlFor($file, $expiresAt); // explicit expiry