Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Think Orm Laravel Package

topthink/think-orm

ThinkORM is the PHP ORM behind ThinkPHP, offering ActiveRecord-style models, a fluent query builder, relationships, events, soft deletes, and multi-database support. Use it with ThinkPHP or standalone for expressive, efficient database access.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. ThinkORM is the standalone ORM extracted from ThinkPHP, a different PHP framework with a different application lifecycle, container, event system, and model conventions. Laravel's architecture is built around Eloquent + the DB facade: service container bindings, model events, policies, API resources, factories, migrations, Telescope/Debugbar introspection, queue serialization, and RefreshDatabase all assume Eloquent. ThinkORM sits outside all of that. It can run standalone inside a Laravel process (it uses PDO and PSR interfaces), but it is a parallel data layer, not a drop-in. Fit is poor for greenfield Laravel; conditionally acceptable only as a coexistence layer during a legacy migration or to reuse a shared ThinkPHP library.

Integration feasibility. Composer-installable, Apache-2.0, no dependency conflicts expected (PSR-3/PSR-16 based). There is no official Laravel service provider, so the integration is bespoke: config bootstrap (Db::setConfig), a container binding, connection lifecycle management, and a testing harness are all yours to build and own. Feasible in a spike; non-trivial in production.

Technical risk.

  • Two ORMs, two sources of truth. Separate connection pools, separate transaction managers, separate query logs. Cross-ORM transactions are not atomic; a request that writes via Eloquent and ThinkORM needs a single PDO connection or a distributed strategy.
  • Convention mismatch. ThinkORM defaults to create_time/update_time and delete_time for soft deletes, versus Laravel's created_at/updated_at/deleted_at. Query-builder vocabulary differs (field/select/find/insert vs select/first/get/create).
  • Observability blind spot. ThinkORM queries will not appear in Telescope, Debugbar, or Laravel's query log without custom instrumentation — a real incident-response cost.
  • Serialization and pagination contracts. think\Paginator returns list/total/per_page/current_page, not Laravel's data/meta. API resources and Inertia/Livewire boundaries will need adapters.
  • Support surface. English-language docs and issue triage are thin; the ecosystem is Chinese-first. Apache-2.0 provides fork insurance, but you'd be maintaining a fork of a database layer — high blast radius.
  • Signal quality. 437 stars and "0 dependents" reflect Packagist visibility more than real usage (it ships inside ThinkPHP), so popularity is not a reliable proxy for Laravel-adjacent risk.

Key questions to answer before committing.

  1. What is the actual driver — a ThinkPHP→Laravel migration, a shared internal package, or a specific missing capability? If it's performance, benchmark against Laravel's query builder first.
  2. Which domains need ThinkORM, and can they be isolated behind repository interfaces with no Eloquent leakage?
  3. Who owns the adapter, the test harness, and on-call for two data layers?
  4. What is the exit plan and the time-box for coexistence?
  5. How will query observability, slow-query alerting, and connection pooling work across both layers under Octane/long-running workers?

Integration Approach

Stack fit. Treat ThinkORM as a scoped, secondary data access layer — never as a replacement for Eloquent, and never as the default choice for new code. Isolate it behind repository interfaces so application code depends on the interface, not on think\Db or think\Model. Bind think\Db as a singleton in a service provider, hydrate its config from config/database.php at boot, and register a shutdown hook to close connections.

Migration path (the realistic use case). Phased ThinkPHP→Laravel cutover:

  1. Port the ThinkPHP business logic into Laravel unchanged, still using ThinkORM, so behavior is preserved.
  2. Wrap every ThinkORM access in a repository interface with a contract expressed in domain terms.
  3. Run a parallel Eloquent implementation behind the same interface.
  4. Shadow-read and dual-write on low-risk domains, diff results, then flip per domain.
  5. Decommission ThinkORM domain-by-domain; remove the dependency last.

Compatibility checklist. PHP 8.x and PDO drivers are fine. Validate: timestamp/soft-delete column conventions (either align the schema or override ThinkORM's autoWriteTimestamp and soft-delete field names), pagination response shape against existing API contracts, transaction semantics at the request boundary, and model event hooks that Laravel listeners won't see. Confirm psr/log and psr/simple-cache versions resolve cleanly against the Illuminate stack.

Sequencing.

  1. Spike (1–2 weeks): one read path and one write path through ThinkORM inside Laravel, including a transaction, with a measurable exit criterion.
  2. Adapter foundation: service provider, config hydration, connection lifecycle, query logging bridge into Laravel's log.
  3. Test harness: a RefreshDatabase equivalent that truncates or rolls back ThinkORM connections; without this, CI coverage of the legacy half of the app degrades.
  4. Repository layer: interfaces first, ThinkORM implementations second, Eloquent implementations third.
  5. Shadow traffic and data-diff on the highest-value domain.
  6. Cutover per domain, with ThinkORM removal as an explicit milestone on the roadmap, not an open-ended state.

Operational Impact

Maintenance. You own the Laravel glue permanently. Upstream releases regularly (recent release date) and Apache-2.0 gives fork safety, but every Laravel major upgrade, PHP minor bump, and PDO/driver change must be validated against a second data layer that no Laravel maintainer tests. Budget ongoing adapter maintenance, not a one-time integration.

Support. Documentation and issue triage are predominantly Chinese-language; expect slower resolution for English-reported defects and timezone friction. Pin to a specific version, subscribe to upstream releases, and treat any SQL-injection or deserialization advisory as high-severity until patched — you have no vendor SLA.

Scaling. Throughput for typical OLTP is comparable to Eloquent; the ORM itself is not the bottleneck. The operational scaling risks are elsewhere: two connection pools per PHP-FPM worker or Octane worker, double the open connections, and connection reuse behavior under long-running workers that differs from Laravel's own DB manager. Under Octane, verify ThinkORM's connection caching does not leak state across requests. N+1 behavior follows the ORM's own relation-loading semantics (with/withJoin), which engineers will get wrong by reflex.

Failure modes to instrument for.

  • Split-brain writes: a request succeeds via Eloquent and fails via ThinkORM, or vice versa, with no shared rollback.
  • Transaction leakage: a ThinkORM transaction left open on a pooled connection under Octane.
  • Silent query degradation: slow ThinkORM queries invisible to Telescope and APM unless explicitly bridged.
  • Contract drift: paginator and timestamp field shapes diverging between endpoints served by different ORMs.
  • Cache key collisions and stale reads where both layers touch the same rows with different invalidation logic.
  • Upgrade breakage: a Laravel or PHP upgrade ships, the adapter breaks, and no upstream test would have caught it.

Ramp-up. A competent Laravel developer needs roughly two to four weeks to be productive in ThinkORM (query builder vocabulary, relation loading, model conventions, pagination shape). On-call readiness is the larger cost: responders must hold two mental models, two debugging toolchains, and know which layer owns a given table. That is a durable tax on the team, not a one-time onboarding cost — and it is the strongest argument for time-boxing ThinkORM's presence in the stack rather than letting it settle in as a permanent second ORM.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle