ilhamarrouf/slim-filesystem

Slim Framework FileSystem abstraction layer library

0.1.0 2019-09-12 12:33 UTC

This package is auto-updated.

Last update: 2024-04-15 13:50:51 UTC


README

A simple filesystem for PHP slim framework like Laravel Storage.

Getting Started

Slim Filesystem can be installed with Composer.

With Composer

If you're already using Composer, just add ilhamarrouf/slim-filesystem to your composer.json file. Slim Filesystem works with Composer's autoloader out of the bat.

{
	"require": {
		"ilhamarrouf/slim-filesystem": "0.1.0"
	}
}

Or

composer require ilhamarrouf/slim-filesystem

Usage

Basic example usage package on Slim 3.x

$settings = [
    'settings' => [
        'filesystem' => [
            'default' => 'cloud',
            'cloud' => 'minio',
            'disks' => [
                'public' => [
                    'driver' => 'local',
                    'root' => __DIR__.'/storage/',
                    'url' => $_SERVER['HTTP_HOST'].'/storage',
                    'visibility' => 'public',
                ],
                's3' => [
                    'driver' => 's3',
                    'key' => 'superkey',
                    'secret' => 'supersecret',
                    'region' => 'us-east-1',
                    'bucket' => 'test',
                    'url' => 'http://host-to-aws-s3',
                ],
                'minio' => [
                    'driver' => 's3',
                    'endpoint' => '127.0.0.1:9000',
                    'use_path_style_endpoint' => true,
                    'key' => 'superpersonalket',
                    'secret' => 'superpersonalsecret',
                    'region' => 'us-east-1',
                    'bucket' => 'tms',
                ],
            ]
        ],
    ],
];

$app = new \Slim\App($settings);

$container = $app->getContainer();

$container['storage'] = function ($container) {
    return new \Ilhamarrouf\Filesystem\FilesystemManager($container);
};