rotexsoft/leanorm

A Generic Data Objects ( https://github.com/rotexsoft/gdao ) implementation based on a stripped down version of idiorm (\LeanOrm\DBConnector). A light-weight, highly performant PHP data access library.

2.2.1 2023-01-27 23:18 UTC

This package is auto-updated.

Last update: 2023-01-28 04:10:10 UTC


README

Run PHP Tests and Code Quality Tools   GitHub release (latest SemVer)   GitHub   Coverage Status   GitHub code size in bytes   Packagist Downloads   GitHub top language   Packagist PHP Version Support   GitHub commits since latest release (by date)   GitHub last commit   GitHub Release Date   Libraries.io dependency status for GitHub repo

LeanOrm

A light-weight, highly performant PHP data access library. Good alternative to Doctrine & Eloquent without all the bells & whistles that are not needed in most applications.

Installation Requirements

PHP 7.4+.

Composer

Version 2.X of this package has been rigorously tested against sqlite 3.7.11+, MySQL 8.0.29+ & Postgresql 15.1+.

MS SQL Server, is theoretically supported but hasn't been tested. Will provide more updates on MS SQL Server support once testing on that DB engine has been done.

If you are using Sqlite, version sqlite 3.7.11 or higher is required.

Version 1.X of this package never got a stable release. Please use version 2.X+ of this package.

Installation

composer require rotexsoft/leanorm

There's an accompanying command-line tool that can be used to automatically generate Model, Record & Collection classes for the tables and views in a database. To install this tool, just run the command below. Read the documentation for the tool for more information.

composer require --dev rotexsoft/leanorm-cli

Running Tests

./vendor/bin/phpunit --coverage-text

You can set the environment variable LEANORM_PDO_DSN with a valid $dsn string for pdo e.g. LEANORM_PDO_DSN=sqlite::memory:

You can set the environment variable LEANORM_PDO_USERNAME with a valid $username string for pdo if needed e.g. LEANORM_PDO_USERNAME=jblow

You can set the environment variable LEANORM_PDO_PASSWORD with a valid $password string for pdo if needed e.g. LEANORM_PDO_PASSWORD=some_password

For example:

LEANORM_PDO_DSN=sqlite::memory: LEANORM_PDO_USERNAME=jblow LEANORM_PDO_PASSWORD=some_password ./vendor/bin/phpunit --coverage-text

LEANORM_PDO_DSN="mysql:host=hostname_or_ip_address;dbname=blog" LEANORM_PDO_USERNAME="jblow" LEANORM_PDO_PASSWORD="some_password" ./vendor/bin/phpunit --coverage-text

GDAO Classes & Interfaces

GDAO Classes & Interfaces

LeanORM Classes

  • \LeanOrm\Model extends the abstract \GDAO\Model class
  • \LeanOrm\Model\Record & \LeanOrm\Model\ReadOnlyRecord both implement \GDAO\Model\RecordInterface
  • \LeanOrm\Model\Collection implements \GDAO\Model\CollectionInterface

LeanORM Classes

Documentation

Documentation for the non-stable 1.X version of this package is located at http://rotexsoft.github.io/leanorm/

Documentation for the most recent 2.X+ version can be found here.

Please submit an issue (preferably with a pull request) to address mistakes or omissions in the documentation or to propose improvements to the documentation.

Contributing

PHPUnit Tests are set-up to run in a specific order in phpunit.xml.dist.

Yes, the best practice is for tests to run independently of each other, but because there are fair amount of static methods in the DBConnector class, its tests need to be run first before other Test Classes.

New Test files must be manually added to the phpunit.xml.dist file in order for those new tests to run.