This guide covers the MinIO object storage integration in the Laravel application.
MinIO is an S3-compatible object storage service that runs in your Docker environment. It provides:
- S3-compatible API for file storage
- Built-in web console for file management
- High performance and scalability
- Local development storage solution
MinIO services are configured in both docker-compose.yml and docker-compose.dev.yml:
- MinIO Server: Runs on port 9000 (API)
- MinIO Console: Runs on port 9001 (Web UI)
- Default Credentials: minioadmin/minioadmin
The MinIO disk is configured in config/filesystems.php:
'minio' => [
'driver' => 's3',
'key' => env('MINIO_ACCESS_KEY', env('AWS_ACCESS_KEY_ID')),
'secret' => env('MINIO_SECRET_KEY', env('AWS_SECRET_ACCESS_KEY')),
'region' => env('MINIO_DEFAULT_REGION', env('AWS_DEFAULT_REGION', 'us-east-1')),
'bucket' => env('MINIO_BUCKET', env('AWS_BUCKET')),
'url' => env('MINIO_URL'),
'endpoint' => env('MINIO_ENDPOINT', env('AWS_ENDPOINT')),
'use_path_style_endpoint' => env('MINIO_USE_PATH_STYLE_ENDPOINT', env('AWS_USE_PATH_STYLE_ENDPOINT', true)),
'throw' => false,
'report' => false,
],Add these to your .env file:
# Set MinIO as default filesystem (optional)
FILESYSTEM_DISK=minio
# MinIO Configuration
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_DEFAULT_REGION=us-east-1
MINIO_BUCKET=laravel
MINIO_ENDPOINT=http://localhost:9000
MINIO_USE_PATH_STYLE_ENDPOINT=trueFor Docker environments, the endpoint should be http://minio:9000.
docker-compose up -dRun the setup command to create the bucket and test the connection:
php artisan minio:setupThis command will:
- Create the configured bucket if it doesn't exist
- Test file upload/download/deletion
- Verify the MinIO connection
Visit http://localhost:9001 in your browser:
- Username:
minioadmin - Password:
minioadmin
use Illuminate\Support\Facades\Storage;
// Store a file
$path = Storage::disk('minio')->put('folder/file.txt', $content);
// Retrieve a file
$content = Storage::disk('minio')->get('folder/file.txt');
// Check if file exists
$exists = Storage::disk('minio')->exists('folder/file.txt');
// Delete a file
Storage::disk('minio')->delete('folder/file.txt');
// Get file URL (for public access)
$url = Storage::disk('minio')->url('folder/file.txt');// Handle uploaded files
$request->validate(['file' => 'required|file|max:10240']);
$path = Storage::disk('minio')->putFile('uploads', $request->file('file'));The existing ChatFileService will automatically use MinIO when it's configured as the default disk or explicitly specified.
Run the MinIO integration tests:
php artisan test tests/Feature/MinIOIntegrationTest.php- Check Docker services: Ensure MinIO container is running
- Verify network: Make sure the app container can reach MinIO
- Check credentials: Verify MINIO_ACCESS_KEY and MINIO_SECRET_KEY
- Check endpoint: Use
http://minio:9000for Docker,http://localhost:9000for local
- Create bucket manually: Use the MinIO console at http://localhost:9001
- Check bucket policies: Ensure proper read/write permissions
- Run setup command:
php artisan minio:setupto create and test
- MinIO performs better with larger files (>1MB)
- Use appropriate bucket policies for public/private access
- Consider using CDN for public file distribution
- Monitor storage usage through MinIO console
For production:
- Use strong credentials (not minioadmin/minioadmin)
- Configure proper bucket policies
- Set up SSL/TLS termination
- Consider using external MinIO cluster
- Implement backup strategies
- Monitor storage metrics
- Change default credentials in production
- Use IAM policies for fine-grained access control
- Enable encryption at rest if required
- Implement proper network security (VPC, firewalls)
- Regular security updates for MinIO container