Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cloud Storage

Cloud Storage Laravel Package

google/cloud-storage

Idiomatic PHP client for Google Cloud Storage. Upload, download, and manage buckets/objects, set ACLs, and use the gs:// stream wrapper. Part of the Google Cloud PHP suite with full API docs and authentication guidance.

View on GitHub
Deep Wiki
Context7

Cloud Storage Client for PHP

Frequently asked questions about Cloud Storage
How do I integrate Google Cloud Storage with Laravel’s Filesystem for `Storage::disk('gcs')` support?
Use the `league/flysystem-google-cloud-storage` adapter alongside `google/cloud-storage`. Configure it in Laravel’s `config/filesystems.php` under a new disk (e.g., `'gcs'`), then use `Storage::disk('gcs')->put()` like any other disk. The adapter bridges GCS operations to Laravel’s filesystem abstraction.
What Laravel versions and PHP versions does `google/cloud-storage` support?
The package supports PHP 8.1+ and is compatible with Laravel 10+. For older Laravel versions (e.g., 9.x), ensure PHP 8.0+ is used. Check the [Google Cloud PHP docs](https://github.com/googleapis/google-cloud-php) for version-specific notes, as minor updates may require adjustments.
How do I authenticate `google/cloud-storage` in Laravel? Can I use service accounts?
Yes, use service account credentials via Laravel’s config (e.g., `config('services.gcs.credentials')`). Store the JSON key file securely (e.g., Laravel Forge, Vault) and pass it to `StorageClient` during initialization. For dynamic auth, use Google’s [Application Default Credentials](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md).
Can I use the `gs://` stream wrapper in Laravel? Will it conflict with other stream handlers?
Yes, register the stream wrapper via `$storage->registerStreamWrapper()`, but use it cautiously in production. It enables `file_get_contents('gs://bucket/file')` but may interfere with other stream wrappers (e.g., S3). For Laravel, prefer explicit `StorageClient` usage or wrap it in a service class to avoid global state issues.
How do I handle large file uploads (e.g., videos >100MB) efficiently in Laravel?
Use `StorageClient::upload()` with `resumable: true` for chunked uploads. For Laravel, wrap this in a job (e.g., `UploadFileJob`) and dispatch it via queues. Monitor progress with callbacks or GCS event notifications. Avoid memory issues by streaming files directly from disk or S3.
Is there a way to cache GCS metadata locally to reduce API calls?
Yes, cache object metadata (e.g., size, last-modified) in Redis or Laravel’s cache. Use `StorageClient::object()` to fetch fresh data when needed, but implement a TTL (e.g., 5 minutes) to avoid stale data. For critical apps, consider a hybrid cache with invalidation via GCS event triggers.
How do I set up multi-tenancy with Google Cloud Storage in Laravel?
Scope buckets by tenant (e.g., `tenant-{id}-media`) and instantiate a `StorageClient` per tenant in Laravel’s service container. Use IAM policies to enforce tenant-level permissions. For shared buckets, rely on object prefixes (e.g., `tenant1/files/`) and validate access in middleware or policies.
What are the alternatives to `google/cloud-storage` for Laravel, and when should I use them?
Alternatives include `league/flysystem-google-cloud-storage` (for Filesystem integration) or `aws-sdk/aws-sdk-php` (for S3). Use `google/cloud-storage` if you need direct GCS features (e.g., predefined ACLs, stream wrappers) or plan to use other Google Cloud services. For S3 compatibility, `league/flysystem-aws-s3` is a better fit.
How do I monitor GCS usage and costs in a Laravel application?
Use GCP’s [Cloud Monitoring](https://cloud.google.com/monitoring) to track storage, network, and API costs. In Laravel, log GCS operations (e.g., uploads/downloads) via a custom logging channel and set up alerts for anomalies. Implement lifecycle rules (e.g., auto-delete old files) via GCS console or Laravel’s scheduler.
Can I use `google/cloud-storage` for Laravel queue jobs (e.g., storing failed jobs) or caching?
Yes, configure the GCS queue driver in `config/queue.php` or use it as a cache driver (e.g., `cache:store --driver=gcs`). For failed jobs, store them in GCS via `queue:failed-table` with a custom GCS adapter. Note that GCS isn’t optimized for high-frequency writes like Redis, so benchmark performance for your use case.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai