Download the PHP package tamarackdb/tamarackdb-php without Composer

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

tamarackdb-php

PHP client for TamarackDB, an event store compliant with the DCB specification.

It covers the whole HTTP API: transactions, reading and writing events, projections, projection rebuilds, and pauses. It is a low-level client, meant to be used by an event sourcing framework or directly by an application. It is tested against TamarackDB v0.46.0.

release ci

Requirements

Installation

Connecting

timeout is how long the client waits for a response (60 seconds by default). It includes the time a request waits for its turn in the server's queue: a commit, writeProjections(), the bulk deletes, pause(), resume(), and optimize(). Past it, the client throws a TimeoutException.

Handling a command

A command runs in one transaction, which lives in the server. Each decision reads events, then writes its events, or none. Your event handlers react, your projections are read and written, and the commit writes everything at once, or nothing. How it works is in Transactions.

Reading events

In a transaction

$tx->readEvents() returns a list: every committed event that matches (Event), then every event written earlier in the transaction that matches (PendingEvent). The whole response is read before it returns.

The next call after a read must be appendEvents(), with the events of the decision or an empty list. A decision that rests on no event reads new NoEvents() first. A response cut short, or one the client can't read, abandons the transaction and throws: run the command again.

backwards: true reads the newest events first: the pending events, then the committed ones. limit is the most events returned, pending and committed together. The read's condition still covers every event that matches the query. To give an invoice the next number:

Outside a transaction

$client->readEvents() reads committed events, for a projector that catches up on its own or a projection rebuild. It returns Events, which you iterate once. Pages are fetched as you iterate, and a page cut short is resumed after the last event received, so no event is skipped or repeated.

To follow new events, keep the last Sequence Position you read, and pass it to the next read.

backwards: true reads the newest events first, in a single page of at most pageSize events. It takes no afterSequence.

Queries

Both reads take a Query, new AllEvents(), or new NoEvents().

The filters given together form one item, and an event must match all of them. or() adds another item, and an event matching any item matches the query. Within EventType::in(), any of the types matches. Give Identifier::is() or Metadata::is() twice with the same name to require both values. To add a filter to every item of a query, use map() and with(): $query->map(fn (QueryItem $item) => $item->with(Metadata::is('tenantId', 'acme'))).

In identifiers and metadata, a name with one value maps to a string, a name with several values to a list. NewEvent and QueryItem expose them the same way.

Writing events

Projections

A projection is an opaque payload identified by type and id. In a transaction, it's written with the events it's computed from (see Projections).

Projection rebuilds

Outside a transaction, the client reads committed projections with their version, and writes them with writeProjections(), all or nothing:

replace and delete carry the version read. When it no longer matches, or a created projection already exists, the call throws a ConcurrencyException.

A rebuild is your application's job. The client gives you the calls it needs:

writeProjections() and the bulk deletes wait for their turn in the server's queue. See rebuilds for how to run one.

Pause

While transactions are still open, pause() asks the server again every $retryAfter milliseconds (1000 by default): $client->pause(retryAfter: 200). See Pause.

Errors

Every exception implements TamarackDB\Exception\TamarackDBException.

Exception When
ConcurrencyException 409: a commit whose reads or projections changed since, or a projection version that doesn't match
TransactionBusyException 409: another call still runs on the transaction, for example one that timed out. The transaction goes on
InvalidRequestException 400: the server rejected the request, or a call that breaks a rule of transactions
UnauthorizedException 401: missing or wrong token
TransactionNotFoundException 404: the transaction expired, or an error ended it
PayloadTooLargeException 413: an event, a projection, or the request is too large
InternalErrorException 500
StorageFullException 507: the server's disk is full. Nothing was written; don't retry until the operator frees space
WriteQueueFullException 503: too many requests are waiting in the server's queue
ShuttingDownException 503: the server is shutting down
PausedException 503: beginTransaction() while a pause is requested or in place
TooManyTransactionsException 503: beginTransaction() while the server has as many open transactions as it allows
UnavailableException 503: health() only, storage is unreachable
TransactionAlreadyActiveException beginTransaction() while the client has an active transaction
NoActiveTransactionException a call on a transaction that is over, or getTransaction() without one
TransportException no full response: server unreachable, connection dropped
TimeoutException a TransportException: the client stopped waiting
ProtocolException a response this client can't make sense of
InvalidArgumentException a value that breaks an API rule, caught before sending

Every server error extends ServerException, with $statusCode, $errorCode (such as "ConcurrencyException"), and $detail.

Server state

stats() returns the counters as the server sends them. Their format follows the server version. See Counters for what they mean.

In development mode, a test suite empties the store with:

Development

The integration tests start their own tamarackdb-server processes, with devMode on and a new database, on a free port and on a unix socket. They are skipped unless TAMARACKDB_SERVER_BIN points to a server binary, with tamarackdb-init in the same directory. Build both from a clone of the server repo, at the version stated above, and check it with -version:

License

MIT, see LICENSE.


All versions of tamarackdb-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-curl Version *
ext-json Version *
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 tamarackdb/tamarackdb-php contains the following files

Loading the files please wait ...