PHP code example of 1tomany / storage-bundle

1. Go to this page and download the library: Download 1tomany/storage-bundle 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/ */

    

1tomany / storage-bundle example snippets




namespace App\File\Action\Handler;

use OneToMany\StorageBundle\Contract\Client\ClientInterface;
use OneToMany\StorageBundle\Request\UploadRequest;

final readonly class UploadFileHandler
{
    public function __construct(private ClientInterface $client)
    {
    }

    public function __invoke(string $path, string $format, string $key): void
    {
        // @see OneToMany\StorageBundle\Response\UploadResponse
        $response = $this->client->act(new UploadRequest($path, $format, $key));
    }
}



namespace App\File\Action\Handler;

use OneToMany\StorageBundle\Contract\Action\UploadActionInterface;
use OneToMany\StorageBundle\Request\UploadRequest;

final readonly class UploadFileHandler
{
    public function __construct(private UploadActionInterface $uploadAction)
    {
    }

    public function __invoke(string $path, string $format, string $key): void
    {
        // @see OneToMany\StorageBundle\Response\UploadResponse
        $response = $this->uploadAction->act(new UploadRequest($path, $format, $key));
    }
}

composer