small / swoole-entity-manager-core
ORM designed for swoole. This is the core package. Use it for your from scratch implementation.
Package info
git.small-project.dev/lib/small-swoole-entity-manager
pkg:composer/small/swoole-entity-manager-core
Requires
- php: >=8.3
- ext-mbstring: *
- small/collection: 3.*
- small/forms: 2.*
- small/swoole-db: >=1.3
- small/swoole-patterns: 23.*
- symfony/validator: ^7.1
- symfony/yaml: 7.*
Requires (Dev)
- pestphp/pest: *
- phpstan/phpstan: *
- rector/rector: *
- swoole/ide-helper: 5.1.x-dev
README
Small Swoole Entity Manager is a php ORM designed for swoole.
This is the core package.


Install
Require the package with composer:
composer require small/swoole-entity-manager-core
Swoole 6
Version 2.5.10 fixes three relational/database compatibility defects exposed by
stratified persistence: composite-key joins now chain additional predicates with
AND, PostgreSQL connections accept an explicit port (default 5432), and MySQL
/ PostgreSQL date-time hydration accepts fractional seconds without returning
false.
Version 2.5.9 isolates the entity-manager cache per EntityManagerFactory instance.
Factories using different connection configurations can no longer reuse a manager created
by another factory, preventing cross-test and cross-connection state leakage.
Version 2.5.8 makes the expanded coverage suite independent from a stale Composer
classmap. PHPUnit loads tests/bootstrap.php explicitly, and fresh Composer installs
also register it through autoload-dev.files. This supports source updates performed
over an existing vendor directory without producing Class ... not found failures.
Version 2.5.7 raises the enforced line-coverage threshold to 90% and expands unit, integration, relation, persistence, layer, query-builder, and error-path tests. The coverage command deletes stale reports before every run and fails below 90%.
Version 2.5.6 restores generated-key propagation for small-swoole-db persist threads.
PersistThread::flush(true) executes inserts individually only for connections marked
with PerInsertLastInsertIdInterface, so each entity receives its own generated key and
original primary-key snapshot. MySQL and PostgreSQL batches remain merged.
Since version 2.5, the MySQL connector uses native PDO instead of the removed
Swoole\Coroutine\MySQL client. Swoole 6 makes PDO MySQL coroutine-aware
through runtime hooks.
Enable hooks once during application bootstrap, before database I/O:
if (class_exists(\Swoole\Runtime::class)) {
\Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
}
The connection pool still assigns one PDO connection to one coroutine at a time. Connections must not be shared concurrently between coroutines.
The development image uses PHP 8.4 and Swoole 6.2.1:
docker compose up -d --build
docker compose exec test-small-swoole-entity-manager composer install
docker compose exec test-small-swoole-entity-manager composer tests
Run the complete validation suite with:
./bin/composer tests
Coverage
The test command generates a fresh XML coverage report and enforces at least 90% line coverage:
./bin/composer unit-tests
The covered source scope is unchanged. PostgreSQL remains excluded from this package's current coverage report because its integration suite is not enabled in phpunit.xml; no additional exclusions were introduced to reach the threshold.
Semantic releases
Run the release script from the main or master branch:
bin/release --patch # 2.6.4 -> 2.6.5
bin/release --minor # 2.6.4 -> 2.7.0
bin/release --major # 2.6.4 -> 3.0.0
The script builds the Docker Compose environment, runs the validation suite, updates .version, commits, tags, and pushes the release. The supported SemVer parts are only patch, minor, and major.