From 9e18b7c9d29275674982b000ff6e462f09533a47 Mon Sep 17 00:00:00 2001 From: Made Mas Adi Winata Date: Mon, 9 Feb 2026 23:53:41 +0700 Subject: [PATCH 1/5] app env not printed in unit test --- tests/Logs/LogTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Logs/LogTest.php b/tests/Logs/LogTest.php index 1e1d0fa..36f7169 100644 --- a/tests/Logs/LogTest.php +++ b/tests/Logs/LogTest.php @@ -23,7 +23,6 @@ private function setContext(): void private function setContext2(): void { - putenv('APP_ENV=local'); $meta = new Metadata(); $meta->task_id = '123123'; $meta->identifier = 'spotlibs-unittest'; From 397f0d028637ee1ce92cd252af08d686401473e1 Mon Sep 17 00:00:00 2001 From: Made Mas Adi Winata Date: Thu, 19 Feb 2026 20:59:41 +0700 Subject: [PATCH 2/5] add minio service provider --- src/Providers/MinioStorageServiceProvider.php | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/Providers/MinioStorageServiceProvider.php diff --git a/src/Providers/MinioStorageServiceProvider.php b/src/Providers/MinioStorageServiceProvider.php new file mode 100644 index 0000000..ecca2e6 --- /dev/null +++ b/src/Providers/MinioStorageServiceProvider.php @@ -0,0 +1,86 @@ + + * @license https://mit-license.org/ MIT License + * @version GIT: 0.3.1 + * @link https://github.com/spotlibs + */ + +declare(strict_types=1); + +namespace Spotlibs\PhpLib\Providers; + +use Aws\S3\S3Client; +use Illuminate\Support\ServiceProvider; +use League\Flysystem\AwsS3v3\AwsS3Adapter; +use Illuminate\Support\Facades\Storage; +use Spotlibs\PhpLib\Libraries\StorageDrivers\MinioAdapter; + +/** + * MinioStorageServiceProvider + * + * Service provider for MinIO storage + * + * @category StandardService + * @package ServiceProvider + * @author Made Mas Adi Winata + * @license https://mit-license.org/ MIT License + * @link https://github.com/spotlibs + */ +class MinioStorageServiceProvider extends ServiceProvider +{ + /** + * Bootstrap the application services. + * + * @return void + */ + public function boot() + { + Storage::extend('minio', function ($app, $config) { + // Client for internal Docker network communication + $client = new S3Client([ + 'credentials' => [ + 'key' => $config["key"], + 'secret' => $config["secret"] + ], + 'region' => $config["region"], + 'version' => "latest", + 'bucket_endpoint' => false, + 'use_path_style_endpoint' => true, + 'endpoint' => $config["endpoint"], // e.g., http://minio:9000 + ]); + + $adapter = new AwsS3Adapter($client, $config["bucket"]); + + // Public client for browser-accessible URLs + $publicClient = new S3Client([ + 'credentials' => [ + 'key' => $config['key'], + 'secret' => $config['secret'] + ], + 'region' => $config['region'], + 'version' => 'latest', + 'use_path_style_endpoint' => true, + 'endpoint' => $config['url'] ?? $config['endpoint'], // e.g., http://localhost:9000 + ]); + + // Return your custom MinioAdapter (which extends Filesystem) + return new MinioAdapter($adapter, $config, $publicClient); + }); + } + + /** + * Register the application services. + * + * @return void + */ + public function register() + { + + } +} From af7d2dcdedb89582a896767eeb1e8cd42c031438 Mon Sep 17 00:00:00 2001 From: Made Mas Adi Winata Date: Mon, 30 Mar 2026 14:39:50 +0700 Subject: [PATCH 3/5] add optional recursive parameter --- src/Libraries/StorageDrivers/MinioAdapter.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Libraries/StorageDrivers/MinioAdapter.php b/src/Libraries/StorageDrivers/MinioAdapter.php index 9e81450..6e8aa35 100644 --- a/src/Libraries/StorageDrivers/MinioAdapter.php +++ b/src/Libraries/StorageDrivers/MinioAdapter.php @@ -122,14 +122,15 @@ public function move(string $path, string $newpath): bool /** * Get all files in a directory * - * @param string $dirpath path of the directory + * @param string $dirpath path of the directory + * @param bool $recursive whether to get files recursively or not * * @return bool */ - public function allFiles(string $dirpath): array + public function allFiles(string $dirpath, bool $recursive = false): array { try { - $paths = $this->listContents($dirpath); + $paths = $this->listContents($dirpath, $recursive); return $paths; } catch (\Throwable $th) { throw $th; From 4abb25b8643b60cd7c20afa7cfa0ebe5c38cbbd0 Mon Sep 17 00:00:00 2001 From: Made Mas Adi Winata Date: Tue, 31 Mar 2026 14:12:44 +0700 Subject: [PATCH 4/5] public create dir --- src/Libraries/StorageDrivers/NFS.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Libraries/StorageDrivers/NFS.php b/src/Libraries/StorageDrivers/NFS.php index b19110c..8714af1 100644 --- a/src/Libraries/StorageDrivers/NFS.php +++ b/src/Libraries/StorageDrivers/NFS.php @@ -175,7 +175,7 @@ public function securelinkFolder(string $dirpath): array * * @return void */ - private function createDirectory(string $dirpath): void + public function createDirectory(string $dirpath): void { try { if (!is_dir($dirpath)) { From 535f3ce694b2537d07ab6053d4bceb289d4c8f9c Mon Sep 17 00:00:00 2001 From: Winata Date: Wed, 13 May 2026 09:48:26 +0700 Subject: [PATCH 5/5] fix error handling with exit code --- src/Libraries/StorageDrivers/NFS.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Libraries/StorageDrivers/NFS.php b/src/Libraries/StorageDrivers/NFS.php index 8714af1..ac01180 100644 --- a/src/Libraries/StorageDrivers/NFS.php +++ b/src/Libraries/StorageDrivers/NFS.php @@ -91,7 +91,8 @@ public function delete(string $filepath): bool if (!is_file($filepath)) { return true; } - if (!exec("rm $filepath")) { + exec("rm $filepath", $output, $exit_code); + if ($exit_code != 0) { throw new RuntimeException("Failed to delete $filepath"); } return true;