PHP code example of utopia-php / storage

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

    

utopia-php / storage example snippets




topia\Storage\Storage;
use Utopia\Storage\Device\Local
use Utopia\Storage\Device\S3
use Utopia\Storage\Device\DOSpaces

// Instantiating local storage
Storage::setDevice('files', new Local('path'));

// Or you can use AWS S3 storage
Storage::setDevice('files', new S3('path', AWS_ACCESS_KEY, AWS_SECRET_KEY,AWS_BUCKET_NAME, AWS_REGION, AWS_ACL_FLAG));

// Or you can use DigitalOcean Spaces storage
Storage::setDevice('files', new DOSpaces('path', DO_SPACES_ACCESS_KEY, DO_SPACES_SECRET_KEY, DO_SPACES_BUCKET_NAME, DO_SPACES_REGION, AWS_ACL_FLAG));

$device = Storage::getDevice('files');

//upload
$device->upload('file.png','path');

//delete
$device->delete('path');

bash
composer