Download the PHP package utopia-php/database without Composer

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

Utopia Database

Build Status Total Downloads Discord

Utopia framework database library is simple and lite library for managing application persistency using multiple database adapters. This library is aiming to be as simple and easy to learn and use. This library is maintained by the Appwrite team.

Although this library is part of the Utopia Framework project it is dependency free, and can be used as standalone with any other PHP project or framework.

Upgrading from 7.x? Read CHANGELOG.md lists what is new in each release.

Getting Started

Install using composer:

Concepts

A list of the utopia/php concepts and their relevant equivalent using the different adapters

Filters

Attribute filters encode an attribute's value before it is saved and decode it after it is read. List a filter's name in an attribute's filters.

Custom Document Types

The database library supports mapping custom document classes to specific collections, enabling a domain-driven design approach. This allows you to create collection-specific classes (like User, Post, Product) that extend the base Document class with custom methods and business logic.

Benefits:

Reserved Attributes

Attribute Types

Attributes are built with a factory per type on Utopia\Database\Attribute (Attribute::string(), integer(), lineString(), ...). Their types are cases of Utopia\Query\Schema\ColumnType: String, Varchar, Text, MediumText, LongText, Integer, BigInteger, Float, Double, Boolean, Datetime, Id, Relationship, Object, Point, Linestring, Polygon and Vector. Attribute::TYPES lists them, and object, spatial and vector attributes need an adapter that supports them. Attributes of the other types can hold an array of values (array: true). Arrays and objects are encoded to JSON when stored and decoded back when fetched, where the adapter has no native type for them.

Supported Databases

Below is a list of supported databases, and their compatibly tested versions alongside a list of supported features and relevant limits.

Adapter Status Version
MariaDB ✅ 10.11
MySQL ✅ 8.0
Postgres ✅ 16
SQLite ✅ 3.38
MongoDB ✅ 8.0
Redis ✅ 8.2
Memory ✅ -

✅ - supported

🛠 - work in progress

What an adapter supports is reported by $database->getAdapter()->supports(Capability::...) and $database->getAdapter()->hasFeature(Feature\...::class). Joins and aggregations, for example, run on the SQL adapters.

Limitations

MariaDB, MySQL, Postgres, SQLite

MongoDB

Usage

Connecting to a Database

Utopia\Database\PDO wraps PHP's PDO: it reconnects when a connection is lost outside a transaction and retries the call. Each SQL adapter also accepts a plain PDO. Pass the PDO attributes your application needs; the ones below are what the adapters expect.

MariaDB

MySQL

Postgres

SQLite

MongoDB

Hooks

Document permissions and relationships are hooks. Register both after you create the Database:

Without Hook\Permissions, MariaDB, MySQL and SQLite neither write nor remove permission rows, and without Hook\Relationships no onDelete rule runs. See UPGRADE.md.

To act on database events, register a lifecycle hook. Its handle() receives one typed event object per event, such as Event\Document\Created with its collection and document. A hook that also implements Selective receives only the events its handles() accepts, and one that implements Named replaces the hook already registered under its name and can be silenced by name with silent().

A Utopia\Database\Hook\Transform rewrites SQL statements before they run, and a Utopia\Database\Hook\Decorator modifies the documents that reads and writes return. Both are registered with addHook() too, and removeHook() unregisters a hook. Event\DispatcherHook forwards events to listeners registered per event class and to a PSR-14 dispatcher.

A Utopia\Database\Hook\Queries rewrites the queries of getDocument(), find(), findOne(), cursor(), resolveCursor(), count(), sum() and aggregate() before the read checks its queries; throwing refuses the read. It also runs on the reads those reads make themselves, such as relationship population, so it must return the same queries when given its own output. Writes, and the reads they make themselves, never run it:

Database Methods

Collection Methods

Attribute Methods

Index Methods

Relationship Methods

Document Methods

Joins and Aggregations

The SQL adapters run joins and aggregations (Capability::Joins, Capability::Aggregations). A join names its alias and lists its conditions; a joined collection is read with the same permissions as a direct read of it, and its attributes come back under the join's alias. Aggregations run through aggregate(), which returns one row per group.

Index the attributes your join conditions compare. On MariaDB and MySQL, a one-to-many join can sort the whole join before the limit; see Joins in the upgrade guide for when it does not.

System Requirements

Utopia Framework requires PHP 8.5 or later. We recommend using the latest PHP version whenever possible.

Contributing

Thank you for considering contributing to the Utopia Framework! Check out the CONTRIBUTING.md file for more information.

Copyright and License

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
ext-pdo Version *
ext-mongodb Version *
ext-mbstring Version *
ext-redis Version *
utopia-php/validators Version ^1.0 || ^2.0
utopia-php/console Version ^0.1 || ^0.2
utopia-php/cache Version ^4.0 || ^5.0
utopia-php/pools Version ^2.0
utopia-php/mongo Version ^1.5.4
utopia-php/query Version ^0.7.2
utopia-php/async Version ^0.2
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 utopia-php/database contains the following files

Loading the files please wait ...