rotexsoft/leanorm
Composer 安装命令:
composer require 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.
关键字:
README 文档
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 8.2+ for version 6.x & 7.x
PHP 8.1+ for versions 4.x & 5.x
PHP 7.4+ for versions 2.x & 3.x
Versions 2.x & 3.x of this package have been rigorously tested against sqlite 3.7.11+, MySQL 8.0.29+ & PostgreSQL 15.1+.
Version 4.x & 5.x have been rigorously tested against:
- Sqlite 3.34.1+
- MariaDB 10.4.33+, 10.5.24+, 10.6.17+, 10.11.7+, 11.0.5+, 11.1.4+, 11.2.3+ & 11.4.2+
- MySQL 5.6.51, 5.7.44, 8.0.36+, 8.1.0, 8.2.0, 8.3.0+ & 8.4+
- PostgreSQL 12.18+, 13.14+, 14.11+, 15.6+ & 16.2+
- See run-tests-against-multiple-db-versions.php
Version 6.x & 7.x have been rigorously tested against:
- Sqlite 3.46.1
- MariaDB 10.4.34, 10.5.29, 10.6.25, 10.11.16, 11.4.10, 11.8.6 & 12.2.2
- MySQL 5.6.51, 5.7.44, 8.0.45, 8.4.8 & 9.6.0
- PostgreSQL 12.22, 13.23, 14.22, 15.17, 16.13, 17.9 & 18.3
- See run-tests-against-multiple-db-versions.php & run-tests-against-multiple-db-versions-docker.php
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.
Version 2.x+ of this package is stable & uses aura/sqlquery 2.8.0+ .
Version 3.x+ and higher of this package are also stable & use aura/sqlquery 3.0.0+.
Versions 2.x & 3.x mainly differ in the versions of aura/sqlquery their Model::getSelect(): \Aura\SqlQuery\Common\Select returns and 3.x has a few newer features like Model::fetchOneByPkey($id, array $relations_to_include = []): ?\GDAO\Model\RecordInterface.
Deprecated Utils::search2D(...) in 2.x has been removed in 3.x
Version 6.x is not backwards compatible with 7.x.
Version 5.x is not backwards compatible with 4.x.
Version 4.x is not backwards compatible with 3.x.
Versions 2.x, 3.x & 4.x are feature complete as of July 2024, only bug fixes will be applied to those versions.
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:
- For Postgres, the dsn must include dbname=blog and you should make sure a blog database exists in the Postgres instance. You don't need this for Sqlite, MariaDB or MySql, the database will be programmatically created.
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" LEANORM_PDO_USERNAME="jblow" LEANORM_PDO_PASSWORD="some_password" ./vendor/bin/phpunit --coverage-text
GDAO Classes & Interfaces
Take a look at the code for the most up to date listing of methods
LeanORM Classes
Take a look at the code for the most up to date listing of methods
- \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 version 2.x version can be found here.
Documentation for version 3.x+ can be found here.
Documentation for version 4.0.x+ can be found here.
Documentation for version 4.1.x+ can be found here.
Documentation for version 5.x+ can be found here.
Documentation for version 6.x+ can be found here.
Documentation for version 7.x+ 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.
Class properties and method parameters and variables are all in snake case (e.g. $some_property_name).
Branching
These are the branches in this repository:
- master: contains code for the latest major version (7.x) of this package.
- 6.x: contains code for the 6.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 5.x: contains code for the 5.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 4.1.x: contains code for the 4.1.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 4.0.x: contains code for the 4.0.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 3.x: contains code for the 3.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 2.2.x: contains code for the 2.2.x versions of this package. Only bug fixes should be added to this branch. This branch is feature complete.
- 1.X: contains code for the 1.X versions of this package. This branch is abandoned.
- gh-pages: contains documentation for the 1.X versions of this package. This branch is abandoned.
rotexsoft/leanorm 适用场景与选型建议
rotexsoft/leanorm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 423 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「orm」 「sql」 「data」 「db」 「mysql」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rotexsoft/leanorm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rotexsoft/leanorm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rotexsoft/leanorm 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Kinikit - PHP Application development framework MVC component
Store your language lines in the database, yaml or other sources
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Query filtering in your frontend
统计信息
- 总下载量: 423
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 3
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-07-14
