Download the PHP package justraviga/laravel-dynamodb-extreme without Composer

On this page you can find all versions of the php package justraviga/laravel-dynamodb-extreme. 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-dynamodb-extreme

DynamoDb Query Builder

This is a Query Builder package for DynamoDb access. Inspired by other versions that didn't quite feel eloquent enough (see what I did there?), this one has the following features, just like Laravel:


Get a single Model instance from DynamoDb

Or, to throw Illuminate\Database\Eloquent\ModelNotFoundException if no results are returned:


Get a Collection of Model instances from DynamoDb

Notes:

  1. Only a single Model type is supported here. You must make sure your query will only return models of the same type.
  2. An Exception will be thrown if a property found in the database is not in the $fillable array on the model.
  3. DynamoDb only supports exact matches on Partition keys, and <, <=, =, >=, >, begins_with, and between matches on Sort Keys.

You can optionally sort on the sortKey and limit the number of results:

If you know you're going to exceed the 1mb query size limit of DynamoDb, you can use the getAll() method to make many queries until the entire result set is returned:

You can also get a specific set of results combining limit() and after():

A shortcut for this is built into the paginate method:


Get a collection of models using a Secondary Index

Provided the secondary index is configured (see below), it will be detected from the fields you are querying.


Create a Model instance in DynamoDb

Immediately persist the model with create:

Build the model in memory without making a database query with make:

Alternatively use the new Model() syntax:


Accessing Model attributes

Once you've created your model, attributes are accessed the same as you would with Laravel, using object property syntax:

You can update many properties at the same time using the fill method:

These changes are not automatically persisted back to Dynamo, you need to save them manually:

or

or even, to combine fill and save:

Setup and global config

Environment variables

Configuration options

The config file can be exported with Laravel's publish command: php artisan vendor:publish, it looks like this:

Apart from the environment-based config, here you can specify defaults for partition key, sort key, and global secondary indexes. These are intended to be sensible defaults based on general usage patterns of DynamoDb.

Model Configuration

Creating a model is easy. At a bare minimum, you just need to define the table name, the partitionKey and sortKey, and an array of "fillable" attributes (note the partition and sort keys need to be fillable!):


To write more verbose code, you can create a mapping from internal/database fields to friendly attributes by overriding the fieldMappings protected property. The mappings are applied when fetching from the database and when saving to the database. The rest of the time, you always use the mapped property name.


By default, all models' Partition Keys are built with the model class name followed by a # then a UUID-7 (time-ordered UUID). Sort Keys default to the model name. For example:

You can also change these default values when creating new models by overriding these methods:

Related models

You can configure related models that share the same Partition Key with some minor extra setup:

By default, this uses the Partition key of the parent model, and matches on the Sort key with a "begins_with" query against the child model's class name followed by a hash (#), something like begins_with(sk, 'CHILDMODEL#'). The matching itself can be configured on the child models by overriding the relationSearchParams method:

The related models can be accessed as a Collection using a property of the same name as the relationship method, e.g:

"inline" relations

In addition to using different rows in a DynamoDb table to hold related models, you can use a JSON attribute on a record as a relation. We call this an "inline relation" and they can be accessed the same way as other relations:


If you want to use a secondary index on your table, just define the Partition and Sort Key names in the $indexes array. Be sure to add them to the $fillable array as well.


You can define mappings from secondary indexes to friendly model properties in the $fieldMappings array too.

Minimum Requirements

  1. PHP 8.2
  2. Laravel 10.0

Wishlist

The things we might like to include (eventually) but didn't have time to properly consider:

Wrapping DynamoDb responses in a cache layer

Optionally have models fetched from DynamoDb stored in memory for the duration of the request so multiple calls to the same partition/sort key return the same data without querying Dynamo.

Attribute casts

Similar to the Laravel model $casts array, attributes should be coerced to/from these data types when fetching and saving with DynamoDb.

Extend the Collection class to include filter methods based on DynamoDb models

Potential for new methods on the Collection class for pagination based on the Last Evaluated Key from DynamoDb.

Better documentation 🙈

Docs can always be improved.

Concurrent requests

Figure out how to make many concurrent requests that can be awaited and only continue execution once all of the requests have returned their data.

Table generation in code

Essentially Laravel's migration system for DynamoDb tables

Cascade deletions

Delete related models after deleting a parent model


All versions of laravel-dynamodb-extreme with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^10.0
aws/aws-sdk-php Version ^3.269
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 justraviga/laravel-dynamodb-extreme contains the following files

Loading the files please wait ....