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.
Requires
- php: >=7.4
- atlas/info: ^1.2
- aura/sqlquery: ^2.4
- aura/sqlschema: ^2.0
- psr/log: ^1.1
- rotexsoft/gdao: ^2.2.1
Requires (Dev)
- atlas/pdo: ^1.2
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^9.0
- rector/rector: ^0.15.0
- rotexsoft/versatile-collections: ^5.2
- symfony/polyfill-php80: ^1.26
- symfony/polyfill-php81: ^1.26
- symfony/polyfill-php82: ^1.26
- vimeo/psalm: ^5.4.0
Suggests
- rotexsoft/leanorm-cli: A Command-line tool for rotexsoft/leanorm for generating Model, Record & Collection Classes for tables & views in a specified database.
README
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+.
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
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
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.