Download the PHP package ikhsant/laravel-google-shared-drive without Composer

On this page you can find all versions of the php package ikhsant/laravel-google-shared-drive. 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 laravel-google-shared-drive

Laravel Google Shared Drive

An easy-to-use Laravel package to integrate Google Drive and Shared Drive APIs with minimal setup, featuring a Spatie-inspired Media Library helper for Eloquent models.

Features

Installation

Install the package via Composer:

Run Migrations

The package includes a migration for the media table. Run your migrations to create it:

Configuration

Publish the config file:

This will create a config/google-shared-drive.php file:

Ensure you have your Service Account JSON placed under storage/app/ (e.g., storage/app/google/service-account.json) and configure your .env:

Google Cloud & Shared Drive Setup Guide

To use this package, you need a Google Service Account credentials file (service-account.json) and a shared folder or Shared Drive.

1. How to obtain service-account.json

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Enable the Google Drive API:
    • Navigate to APIs & Services > Library.
    • Search for "Google Drive API" and click Enable.
  4. Create a Service Account:
    • Navigate to APIs & Services > Credentials.
    • Click Create Credentials and choose Service Account.
    • Enter service account details and click Create and Continue, then Done.
  5. Create and download the JSON key:
    • Click on the newly created service account from the list.
    • Go to the Keys tab.
    • Click Add Key > Create new key.
    • Select JSON and click Create.
    • A JSON file will be downloaded. Rename it (e.g. service-account.json) and place it under storage/app/google/service-account.json (or use an absolute path).

2. How to Setup Google Drive / Shared Drive Access

For the service account to interact with your Google Drive folder, you must share the target folder with the service account:

  1. Open the downloaded JSON credentials file.
  2. Find and copy the "client_email" value (looks like [email protected]).
  3. Open Google Drive in your browser.
  4. Right-click the folder or Shared Drive you want to use as the root, and select Share (or Manage members for Shared Drives).
  5. Paste the service account's client email and assign it the Editor (or Content Manager / Contributor) role.
  6. Copy the Folder ID from the browser URL (e.g. in https://drive.google.com/drive/folders/1aBcDeFgHiJkLmNoPqRsTuVwXyZ, the folder ID is 1aBcDeFgHiJkLmNoPqRsTuVwXyZ).
  7. Add this folder ID into your .env file as GOOGLE_DRIVE_ROOT_FOLDER_ID.

Media Library Usage

1. Prepare Your Model

Add the HasMedia trait to your Eloquent model:

2. Upload / Associate Media Fluently

You can upload a file and associate it with the model using the Spatie-inspired fluent API. You can specify a custom nested folder path on Google Drive via toFolder():

Note: Folder path lookup is fully optimized using Laravel's cache. If a folder is manually deleted from Drive, the package auto-detects and self-heals by recreating it.

3. Retrieve / Download Media Contents

Use the relation to get media and retrieve file contents directly:

4. Delete Media

Deleting a media model automatically triggers the model event that deletes the corresponding file from Google Shared Drive:


Low-Level API Usage (Facade)

For direct interactions with Google Shared Drive without database models, use the GoogleSharedDrive facade.

Upload a File

Download File Contents

Delete a File


All versions of laravel-google-shared-drive with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
google/apiclient Version ^2.19
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 ikhsant/laravel-google-shared-drive contains the following files

Loading the files please wait ...