Download the PHP package revolution/laravel-google-photos without Composer
On this page you can find all versions of the php package revolution/laravel-google-photos. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download revolution/laravel-google-photos
More information about revolution/laravel-google-photos
Files in revolution/laravel-google-photos
Package laravel-google-photos
Short Description Google Photos API for Laravel
License MIT
Informations about the package laravel-google-photos
Google Photos API for Laravel
A Laravel package providing seamless integration with the Google Photos Library API and Google Photos Picker API. Upload photos, manage albums, and interact with Google Photos directly from your Laravel applications.
Overview
This package enables Laravel applications to:
- Upload photos to Google Photos with automatic media item creation
- Manage albums - create, list, and update album information
- List media items and search through uploaded content
- Use Google Photos Picker to let users select photos from their Google Photos library
- OAuth 2.0 authentication with proper token management and refresh handling
Important: Due to Google Photos API limitations, you can only access and manage content that was uploaded via your application. For accessing existing user photos, use the Google Photos Picker API.
Quick Start
1. Install the Package
2. Get Google API Credentials
- Visit the Google Cloud Console
- Enable Photos Library API and Google Photos Picker API
⚠️ Be careful not to select "Google Picker API" (different from Photos Picker API) - Create OAuth 2.0 client credentials
- Set authorized redirect URIs for your application
3. Configure Laravel
Add to your config/services.php
:
Edit config/google.php
:
Add to your .env
:
4. Quick Example
Requirements
- PHP >= 8.2
- Laravel >= 11.0
Installation
Authentication
OAuth 2.0 Only
This package ONLY supports OAuth 2.0 authentication.
❌ Service Account authentication is NOT supported
❌ API Key authentication is NOT supported
Why OAuth 2.0 Only? The Google Photos API is designed for user-centric applications and requires user consent to access personal photo libraries. Google Photos API does not support Service Account or API Key authentication methods because:
- Privacy by Design: Photos are personal data requiring explicit user consent
- Google API Limitation: The Photos Library API only accepts OAuth 2.0 tokens
- User Context Required: All operations need to be performed on behalf of a specific user
OAuth Setup Guide
Step 1: Google Cloud Console Setup
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable these APIs:
- Photos Library API (for uploading and managing photos)
- Google Photos Picker API (for photo selection interface)
- Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
- Choose "Web application"
- Add your authorized redirect URIs (e.g.,
https://yourapp.com/auth/google/callback
)
Step 2: Laravel Configuration
The 'access_type' => 'offline'
setting is required to obtain refresh tokens for long-term access.
Step 3: OAuth Implementation with Laravel Socialite
Usage Examples
Upload Photos
Photos must be uploaded using a two-step process:
List Media Items
Create Album
List Albums
Update Album Title
Using with User Model Trait
Add the PhotosLibrary
trait to your User model for cleaner syntax:
Google Photos Picker API
Use the Picker API to let users select existing photos from their Google Photos library:
Advanced Usage
PhotosLibraryClient Methods
This package delegates to the Google Photos Library PHP client and supports all its methods:
PagedListResponse
Methods like listMediaItems()
and listAlbums()
return a PagedListResponse
for handling large result sets:
Error Handling
Extending with Macros
You can extend the Photos facade with custom methods:
FAQ
Can I use a Service Account?
No. Service Account authentication is not supported by the Google Photos API. The API requires OAuth 2.0 user consent because it deals with personal photo data.
Can I use an API Key?
No. API Key authentication is not supported by the Google Photos API. Only OAuth 2.0 authentication is available.
Why only OAuth 2.0?
Google Photos API is designed exclusively for user-centric applications. Since photos are personal data, Google requires explicit user consent through OAuth 2.0. This ensures users maintain control over their photo data and can revoke access at any time.
Can I access existing photos in a user's Google Photos library?
No, not directly. The Google Photos Library API only allows access to photos uploaded via your application. To work with existing user photos, you must use the Google Photos Picker API included in this package.
Do I need review for production use?
If you're only uploading to your own account during development, no review is needed. However, for production use with other users' accounts, Google requires app review for sensitive scopes.
What are the API limits?
Google Photos API has rate limits and quotas. See the official documentation for current limits.
Related Packages
- laravel-google-sheets - Google Sheets API integration
- laravel-google-searchconsole - Google Search Console API integration
Resources
- Google Photos Library API Documentation
- Google Photos Picker API Documentation
- Laravel Socialite Documentation
- Package Documentation
License
MIT
⚠️ Important Note: This package can only access photos uploaded via your application. For accessing existing user photos, use the Google Photos Picker API functionality included in this package.
All versions of laravel-google-photos with dependencies
illuminate/support Version ^11.0||^12.0
revolution/laravel-google-sheets Version ^7.0
google/photos-library Version ^1.7