Download the PHP package affordablemobiles/eloquent-datastore without Composer

On this page you can find all versions of the php package affordablemobiles/eloquent-datastore. 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 eloquent-datastore

Laravel Eloquent for Google Datastore

Latest Stable Version License

A package for using Google Datastore as a database driver.


By using this package, you can use query builder and eloquent to access data from datastore.

Installation

This package requires PHP 8.3 as a minimum.

This branch targets Laravel 12.x. For compatibility with other Laravel versions, please see the appropriate branch.

You can install the package via composer:

If you are using Laravel Package Auto-Discovery, you don't need you to manually add the ServiceProvider.

Without auto-discovery:

If you don't use auto-discovery, add the below ServiceProvider to the $providers array in config/app.php file.

Roadmap

Usage

You need to add datastore connection in config/database.php file.

Access using Eloquent Model

You need to extend AffordableMobiles\EloquentDatastore\Eloquent\Model class instead of Laravel's default Eloquent model class.

Example-

Access using Query Builder

Example-

It will return a collection.

Understanding Primary Keys: __key__ vs. $primaryKey vs. id

To use this driver effectively, it's important to understand how it handles Datastore's keys.

1. The "Ground Truth": Datastore's __key__

In Google Datastore, the true primary key for every entity is the __key__ property. This is a complex Key object that contains the Kind, the scalar identifier (a string name or numeric ID), and any ancestor information. All final database operations (lookups, saves, deletes) must use this Key object.

2. The Eloquent Layer (Recommended)

The Eloquent Model (e.g., App\Models\User) provides a high-level, model-aware abstraction.

3. The Base Query Builder (The "Escape Hatch")

If you bypass Eloquent and use the base Query Builder (e.g., DB::table('users') or User::query()->toBase()), you are in a model-agnostic layer. This layer does not know about your model's $primaryKey = 'uuid' alias.

Caching & Performance

This package automatically integrates with laravel-eloquent-query-cache to cache results. By default, caching is opt-in per model. To enable it, add the $cacheFor property to your model:

Smart Lookup Optimization

Google Datastore "Lookups" (retrieving by Key) are significantly faster, cheaper, and more consistent than "Queries" (scanning indexes).

This driver automatically optimizes standard Eloquent queries into Datastore Lookups whenever possible. If you filter by the model's primary key (e.g., id, uuid, or __key__), the driver converts the operation into a direct lookup() call internally. This ensures that these operations hit the cache and use the most efficient Datastore operation.

Cached & Optimized Operations:

The following operations are automatically converted to Lookups and will use the cache:

Uncached Operations:

Complex queries that require an index scan are not cached by default (to prevent cache explosion and stale data issues with ranges).

Key Normalization

Datastore IDs can be either integers or strings. To ensure consistent caching and prevent misses, this driver automatically normalizes all IDs in cache keys and tags to strings. This means you do not need to worry about casting IDs (e.g. (int) $id) when interacting with the cache; the driver handles it for you.

Safety & Limitations

Partial Updates Protection

Datastore's upsert operation replaces the entire entity. This poses a risk if you fetch a partial model (e.g., using select() or keysOnly()) and then try to save() it, as you would accidentally delete all the attributes you didn't select.

To prevent data loss, this driver blocks saving of partial models.

If you need to update a record, ensure you fetch the full entity first:

Tested Builder Functions

Contribution Guide

You can contribute by reporting bugs, fixing bugs, submitting and reviewing pull requests.

Go to issues section, and you can start working on an issue immediately.

License

The MIT License (MIT). Please see License File for more information.


All versions of eloquent-datastore with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
illuminate/support Version ~12
illuminate/pagination Version ~12
illuminate/database Version ~12
illuminate/http Version ~12
google/cloud-datastore Version ^1.32.3
affordablemobiles/laravel-eloquent-query-cache Version ~12
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 affordablemobiles/eloquent-datastore contains the following files

Loading the files please wait ...