Download the PHP package mathsgod/light-db without Composer

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

GitHub PHP CI Tests MySQL MariaDB

Light-DB

Light-DB is a lightweight PHP ORM/database access layer built on top of Laminas DB, designed for modern PHP 8.2+ applications. It provides an Eloquent-like Active Record experience with support for auto-mapping, dynamic queries, relationship queries, JSON field operations, and pagination โ€” with first-class compatibility for both MySQL 8.0 and MariaDB 10.11 / 11.4.

โœจ Features

๐Ÿ“‹ Requirements

๐Ÿš€ Installation

Install via Composer:

โš™๏ธ Configuration

Create a .env file in your project root:

๐ŸŽฏ Basic Usage

Defining Models

CRUD Operations

Creating Records

Querying Records

Updating Records

Deleting Records

๐Ÿ” Advanced Queries

Query Conditions

Sorting and Limiting

OR / AND Logic with filters()

Use the _or and _and magic keys inside filters() to build boolean logic.

Mixing outer where() with inner _or / _and:

Nested _or and _and for deeper boolean trees:

Alternatively, the underlying Laminas\Db\Sql\Select::where() accepts a combination operator:

Tip: filters(['_or' => ...]) is generally easier to read and supports arbitrary nesting. Use the direct where(..., OP_OR) form when you need fine-grained control over a single predicate.

Aggregate Functions

๐Ÿ“„ Pagination

๐Ÿ”„ JSON Field Operations

Note: MariaDB stores JSON columns as LONGTEXT with a JSON_VALID() CHECK constraint. Light-DB detects this at runtime and treats them as json data type for transparent encoding/decoding.

๐Ÿ”— Relationship Queries

๐Ÿ› ๏ธ Advanced Features

Declarative Filters & Sorts (Model::boot())

A model's relation-based or computed filters and sorts can be declared on the model itself instead of being registered ad-hoc from controllers. Light-DB auto-invokes the model's boot() lifecycle method the first time Model::Query() is called for the class, so registrations are guaranteed to be in place before any filter is resolved.

Override filterDefinitions() and / or orderDefinitions() to return an [name => callable] map:

After this, any caller of Schedule::Query()->filters(['Letter' => $v]) โ€” including sub-queries from unrelated code paths โ€” gets the right SQL, without the controller having to call RegisterFilter() first. Boot is idempotent per process per class, so multiple Query::Query() invocations don't double-register.

Inheritance via parent:::

Borrow a filter from another class:

The legacy Model::RegisterFilter() / Model::RegisterOrder() APIs are still supported and remain the right choice when the registration depends on request-scoped state (current user, request params, etc.) that the static filterDefinitions() hook cannot see. Both styles can coexist on the same model.

Collection Operations

Custom Sorting

Prefer orderDefinitions() on the model itself for new code โ€” see Declarative Filters & Sorts.

Binding Input Parameters to Prepared Statements

Both cursor() and execute() accept an optional array $input_parameters = [] argument. These parameters are bound to the underlying Laminas\Db\Adapter\ParameterContainer and matched against the ? placeholders that Light-DB/Laminas auto-generates for where conditions. Both methods iterate the same way and return hydrated model instances.

input_parameters is a thin pass-through to the prepared statement. Use it when you want to be explicit about what gets bound:

Note: If you pass keys that don't match any ? token in the query, the database driver will reject the statement with HY093 (PDO: "number of bound variables does not match number of tokens"). The placeholder count is determined by your where/filter/join expressions โ€” Light-DB does not invent extra ? tokens for unused parameters.

๐Ÿ—„๏ธ Database Compatibility

Database Version Status
MySQL 8.0 โœ… Fully supported
MariaDB 10.11 โœ… Fully supported
MariaDB 11.4 โœ… Fully supported

Light-DB automatically detects MariaDB at connection time by inspecting SELECT VERSION(). Internally, this enables:

๐Ÿงช Running Tests

A .env file with valid database credentials is required (see Configuration).

โœ… Continuous Integration

Tests run automatically on every push and pull request via GitHub Actions. The CI matrix covers:

That gives 12 parallel jobs ensuring compatibility across the supported matrix.

๐Ÿ“Š Test Coverage

๐Ÿ“ฆ Dependencies

Package Version Purpose
laminas/laminas-db ^2.20 Database abstraction layer
laminas/laminas-paginator ^2.20 Pagination support
illuminate/collections ^11.0 \|\| ^12.0 Eloquent-style collections
vlucas/phpdotenv ^5.6 Environment variable loading

๐Ÿ“ License

This project is licensed under the MIT License.

๐Ÿ‘จโ€๐Ÿ’ป Author

Raymond Chong

๐Ÿค Contributing

Issues and Pull Requests are welcome!

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“š More Examples

Check the test files in the tests/ directory for more usage examples and best practices.


All versions of light-db with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-pdo Version *
vlucas/phpdotenv Version ^5.6
illuminate/collections Version ^11.0 || ^12.0
laminas/laminas-db Version ^2.20
laminas/laminas-paginator Version ^2.20
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 mathsgod/light-db contains the following files

Loading the files please wait ...