Download the PHP package open-php/google-drive-uploader without Composer

On this page you can find all versions of the php package open-php/google-drive-uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package google-drive-uploader

Google Drive Uploader Library

Latest Version on Packagist Total Downloads License CI

A simple, robust PHP library for uploading files to Google Drive. It handles creating folders, setting public permissions, and most importantly, automatic token refreshing and retries (self-healing auth) to handle the dreaded 7-day token expiry for testing apps.

Features

Installation

Install via Composer:

Google Cloud Setup

To use this library, you need credentials from the Google Cloud Console.

  1. Go to Google Cloud Console.
  2. Create a Project.
  3. Enable Google Drive API.
  4. Go to Credentials -> Create Credentials -> OAuth Client ID.
  5. Application Type: Web Application.
  6. Redirect URI: http://localhost/callback.php (or your production URL).
  7. Download the JSON and save it as credentials.json.
  8. Important: While your OAuth consent screen is in "Testing" mode, refresh tokens for external users can expire after 7 days. Moving the app to production may change this behavior, subject to Google's OAuth policies. The library can refresh access tokens only while Google accepts the stored refresh token.

Keep credentials.json and token.json private. Do not commit them to source control or expose them through a public web directory; restrict filesystem access to the application account.

Usage

1. Initialization

2. First-Time Authentication

If you don't have a token.json yet, you need to authorize the app.

3. Uploading a File

4. Uploading Multiple Files

To upload efficiently (checking folder existence only once):

5. Deleting a File

You can permanently delete a file using its File ID:

6. Renaming a File

You can rename a file using its File ID:

7. Downloading a File

Download a Drive file to a local path. The destination directory must already exist and be writable by PHP.

downloadFile requires Google Drive to provide a download link for the file.

Laravel Integration

This package is framework-agnostic, but can be used in Laravel. The example below shows one way to connect the library's OAuth flow to Laravel routes.

1. Define Routes

In routes/web.php:

[!IMPORTANT] Google Cloud Console Setup You MUST add the full callback URL to your Authorized redirect URIs in the Google Cloud Console.

If your app runs at http://localhost:8000, add: http://localhost:8000/google/callback

If your app runs at http://localhost/myapp/public, add: http://localhost/myapp/public/google/callback

The URL must match EXACTLY what your Laravel app generates.

2. The Controller

How to Display Files (Blade Example)

Different file types require different HTML tags.

Controller: Pass the id and mimeType to your view.

View (googleFileView.blade.php):

Support

License

This project is licensed under the MIT License. See LICENSE file for details.

Disclaimer

This independent open-source project is not affiliated with, endorsed by, or sponsored by Google LLC. Google Drive and Google are trademarks of Google LLC.

You are responsible for securing OAuth credentials and tokens, configuring Google Cloud permissions, and complying with Google's applicable terms and policies. Do not expose credentials or tokens in public repositories, client-side code, or public directories.

Author


All versions of google-drive-uploader with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
google/apiclient Version ^2.15
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package open-php/google-drive-uploader contains the following files

Loading the files please wait ...