league/flysystem-google-cloud-storage
Flysystem adapter for Google Cloud Storage (GCS). Install via composer to use GCS as a filesystem in Flysystem, with full support through the main Flysystem project. See official docs for configuration and usage.
Strengths:
Storage facade).Fit for Laravel:
filesystem configuration (e.g., config/filesystems.php), replacing or extending existing adapters (e.g., local, s3).Weaknesses:
Storage::put() with symlink handling or cache tags).Laravel Compatibility:
config/filesystems.php:
'disks' => [
'gcs' => [
'driver' => 'google',
'bucket' => env('GCS_BUCKET'),
'project_id' => env('GCS_PROJECT_ID'),
'key_file' => env('GCS_KEY_FILE'),
// Optional: custom endpoint, region, etc.
],
],
Google_Auth_AssertionCredentials) for CI/CD pipelines.GCS-Specific Requirements:
gsutil or client libraries).Google\Cloud\Storage\StorageClient directly).google/cloud-storage) as a fallback for unsupported features.spatie/flysystem-circuit-breaker).local, s3, or ftp disks in config/filesystems.php.spatie/laravel-medialibrary, intervention/image, or league/flysystem-aws-s3-crc32 (if hybrid setups are needed).spatie/laravel-image-optimization).Phase 1: Pilot Disk
gcs_backups) to test non-critical files (e.g., logs, exports).Storage facade compatibility (e.g., Storage::disk('gcs')->put()).Phase 2: Primary Storage
local disk) or direct uploads (via Storage::put).storage:writing).Phase 3: Advanced Features
google-cloud-storage JS client) for direct user uploads.Storage::lock() as a workaround).spatie/laravel-activitylog (if logging file operations).fruitcake/laravel-cors (if using direct client uploads).| Step | Task | Dependencies | Tools |
|---|---|---|---|
| 1 | Set up GCS bucket | Google Cloud project, IAM roles | gcloud CLI, Terraform |
| 2 | Configure Laravel filesystems.php |
GCS credentials | env() variables |
| 3 | Test basic CRUD | Laravel Storage facade | PHPUnit, Tinker |
| 4 | Migrate existing files | Backup strategy | rsync, gsutil |
| 5 | Update app logic | URL generation, events | Laravel Storage helpers |
| 6 | Monitor performance | GCS metrics, Laravel logs | Cloud Monitoring, Sentry |
| 7 | Roll out to production | Canary release | Laravel Forge/Vapor |
Pros:
Cons:
403 Permission Denied) require familiarity with IAM roles.Maintenance Tasks:
storage.objectAdmin roles.connect_timeout in Laravel’s HTTP client if latency isHow can I help you explore Laravel packages today?