Skip to content

A lightweight remote file storage library for PHP & Symfony. It provides one interface to interact with the commonly used remote filesystems, such as AWS S3

License

Notifications You must be signed in to change notification settings

SchwarzIT/php-remote-storage

Repository files navigation

aino

A Minimal PHP Remote Storage Library

Manage the remote files with minimal dependency

PRs Welcome chapter-php


Supported Remote Storage

the following remote storage are supported in this library:

  • AWS S3 Bucket
  • SFTP file server 🛠
aino

I used the MinIO docker instead of AWS S3 for local testing

aino

Symfony + AWS S3 Demo: List, download, delete, upload file object in Symfony5 Demo

Install

git clone https://github.com/SchwarzIT/php-remote-storage.git storage && cd storage
make install

Run Tests

make test 

http://localhost:9001/ for MinIO bucket (the credentials are test data for local env.)

  • Access-Key: I3uWTHZGke8RWa1j
  • secret-Key: G0OC3OYQ5Qw59z61

Use the S3Adapter in pure PHP

// instantiate S3 File system
$S3Adapter = new S3Adapter($s3Client, self::TEST_S3_BUCKET);

// upload a test file
$S3Adapter->save($pngFile);

// delete a test file
$S3Adapter->delete($pdfFile);

// load a test file
$S3Adapter->get($pdfFile);

// @more info see S3AdapterTest.php

Use the S3Adapter in Symfony Project

config the AWS S3 Client and S3Adapter

## config/packages/s3.yaml
services:
    Aws\S3\S3Client:
        arguments:
            -   region: '%env(S3_REGION)%'
                endpoint: '%env(S3_ENDPOINT)%'
                version: '2006-03-01'
                use_path_style_endpoint: true
                credentials:
                    key: '%env(S3_ACCESS_KEY)%'
                    secret: '%env(S3_ACCESS_SECRET)%'

    Chapterphp\Storage\RemoteStorageInterface: '@Chapterphp\Storage\S3Adapter'

config the services for the package ``

### config/services.yaml
services:
    Chapterphp\Storage\S3Adapter:
        arguments:
            $s3Bucket: '%env(S3_BUCKET)%'

licence

apache-2.0 [email protected]

About

A lightweight remote file storage library for PHP & Symfony. It provides one interface to interact with the commonly used remote filesystems, such as AWS S3

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published