Download the PHP package debuss-a/flora without Composer

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

Flora

A FaunaDB-like document store on top of SQL, queried with functions modelled on FQL.

Status: proof of concept, for PostgreSQL, MySQL, MariaDB and SQLite.

Setup

Using Flora with an AI assistant

AI.md is a guide for AI coding assistants: the rules, shapes, renamed FQL functions and recipes they need to write correct queries. No assistant reads vendor/ on its own: point yours to it from your project.

Tests keep the guide in step with the library. tests/Unit/AiGuideTest.php checks that it names every function, that its examples call none that does not exist, and that its table of renamed FQL functions gives names that exist. tests/Integration/AiGuideTestCase.php runs its examples as they are written, in order, on each database, and checks what it says of the results: their shapes, the order of pages, bounds, joins, history.

Collections and documents

Refs can be stored in documents (['author' => $ada['ref']]), indexed and matched like any other value.

Data is JSON written as PHP arrays, plus refs, instants and dates. Objects are arrays with string keys, so an empty object comes back as an empty list, and stdClass is refused: decode JSON with json_decode($json, true). Data comes back as it was written, fields starting with @ included: Flora tags its own values as {"@ref": ...}, {"@ts": ...} and {"@date": ...}, and stores a field of the application starting with @ with another one ("@type" as "@@type"). Index paths name fields as they are written (['data', '@type']).

Ids are Snowflake ids: 64-bit, sorted by creation time, generated in PHP. Snowflake::createdAt($id) tells when an id was made. NewId() gives one without creating a document, for a document whose ref is needed first.

Delete(Collection('users')) deletes a collection with its documents, their history and its indexes, and returns it as it was. The name can then be given to another one.

Indexes

Unrolling lists

Combining sets

Joins

Ranges

Filtering

Counting and reducing

Lists, objects and sets

Strings and types

Stored functions

The schema

Writing in bulk

Time

Dates

History

Composing queries

Arrays are evaluated too, so $client->query([Get($a), Get($b)]) reads both documents in one transaction.

Differences with FQL

FQL Flora Why
Match MatchIndex match is a PHP keyword
Var Variable var is a PHP keyword
If IfElse if is a PHP keyword
And All and is a PHP keyword
Or Any or is a PHP keyword
Foreach Each foreach is a PHP keyword
Count Size count() is a PHP function
Max Greatest max() is a PHP function
Min Least min() is a PHP function
Abs Absolute abs() is a PHP function
Time Timestamp time() is a PHP function
Date ToDate date() is a PHP function
Range Between range() is a PHP function
Trim, LTrim, RTrim TrimStr, LTrimStr, RTrimStr trim(), ltrim() and rtrim() are PHP functions
IsSet IsSetRef isset is a PHP keyword
Function FunctionRef function is a PHP keyword
Do Sequence do is a PHP keyword

Function names are case-insensitive in PHP: a function imported with use function takes the place of the PHP function of the same name in that file, and would silently return an expression. Flora's functions therefore avoid the names of PHP's, except Join: importing it hides join(), the alias of implode(). Frameworks define global functions too: in a Laravel application, importing Now hides the now() helper in that file.

Not there yet: other databases.

Errors

All exceptions implement Flora\Exception\FloraException: NotFound, AlreadyExists, NotUnique, InvalidArgument, Aborted and Contended. A failing query rolls back all of its writes.

Contended means that the query ran into other transactions: it waited too long for a lock (SQLite's busy timeout, innodb_lock_wait_timeout, lock_timeout), or the database stopped it to break a deadlock. It wrote nothing and can be run again, or answered with a 503.

NotUnique::$index names the unique index the write broke, to tell which value is taken:

Drivers

A database is supported by implementing Flora\Driver\Driver: collection and index creation, reads and writes by id, and an index scan with cursors. The query language does not depend on it, and all drivers pass the same integration tests.

PostgreSQL (12+) MySQL (8.0.17+) MariaDB (10.11+) SQLite (3.38+)
data column JSONB JSON JSON (checked text) TEXT (checked JSON)
Index expression index on the paths indexed virtual columns indexed virtual columns indexed virtual columns
36 and 36.0 the same term the same term the same term the same term
Object terms key order ignored key order ignored key order ignored key order matters
String order the database collation code point code point code point
Lists, objects by size, then items; [] first by JSON text by JSON text by JSON text
Large integers exact sorted as doubles sorted as doubles exact
Nesting depth 512 levels (PHP's JSON) 100 levels 31 levels 512 levels (PHP's JSON)
Long values index entries up to ~2 KB keys cut at 128 chars keys cut at 128 chars no limit
Object keys sorted by JSONB sorted by MySQL kept as written kept as written
Schema changes transactional commit the transaction commit the transaction transactional

Virtual columns: MySQL, MariaDB and SQLite

MariadbDriver and AbstractVirtualColumnsDriver, and differ only in the SQL that declares tables and indexes and reads JSON. Each driver checks in install() that the database is the right one, and recent enough.

MySQL and MariaDB (AbstractMysqlDriver):

SQLite:

Tests

The integration tests in tests/Integration/*TestCase.php run on each driver (tests/Integration/Postgres, tests/Integration/Mysql, tests/Integration/Mariadb, tests/Integration/Sqlite); a driver's tests are skipped when its database is not reachable. SQLite runs in memory, without Docker.

Two tests run on data made to catch what databases do differently (tests/Integration/AuditFixture.php: numbers near the limits of integers and doubles, strings in several scripts, null and missing fields, lists, objects, refs, instants, dates, as the values of indexes):

PHPStan checks the library at its strictest level (phpstan.dist.neon), and the tests at level 8 (phpstan.tests.neon): what queries return is mixed by nature.

The GitHub Actions workflow (.github/workflows/ci.yml) runs PHPStan, and the tests on PHP 8.4 and 8.5 against the databases of compose.yaml, as services. There, a skipped test fails the build: a database that did not start would otherwise go unnoticed.

License

Flora is released under the MIT License.


All versions of flora with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-json Version *
ext-mbstring Version *
ext-pdo 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 debuss-a/flora contains the following files

Loading the files please wait ...