Skip to content

chore: replace utopia-php/framework with standalone packages#837

Open
loks0n wants to merge 5 commits intomainfrom
chore/remove-databases
Open

chore: replace utopia-php/framework with standalone packages#837
loks0n wants to merge 5 commits intomainfrom
chore/remove-databases

Conversation

@loks0n
Copy link
Contributor

@loks0n loks0n commented Mar 13, 2026

Summary

  • Replace utopia-php/framework dependency with utopia-php/validators (0.2.) and utopia-php/console (0.1.) — the only parts of the framework this library actually uses
  • Update Utopia\CLI\Console imports to Utopia\Console in src and tests

Test plan

  • Verify composer install resolves dependencies correctly
  • Run full test suite to confirm no breakage
  • Confirm bin/ CLI scripts still work (they use utopia-php/cli from dev dependencies)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Updated package requirements and dependency versions.
  • Bug Fixes

    • Improved tenant handling and validation for consistent multi-tenant behavior across database operations.
  • Maintenance

    • Adjusted CLI/import namespaces across tooling and scripts for consistency.

…opia-php/console

Remove the heavy framework dependency in favor of the lightweight
standalone packages that this library actually uses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c8dc678-5b4c-45d4-9495-018bfc0d285b

📥 Commits

Reviewing files that changed from the base of the PR and between a0b48ed and 2242d29.

📒 Files selected for processing (1)
  • src/Database/Document.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Database/Document.php

📝 Walkthrough

Walkthrough

Updated dependencies and Console import namespaces; narrowed tenant types to strings and added per-document tenant extraction/propagation and validation in shared-table database flows.

Changes

Cohort / File(s) Summary
Dependencies
composer.json
Removed utopia-php/framework; added utopia-php/validators and utopia-php/console; bumped dev utopia-php/cli version.
Console import updates
bin/cli.php, bin/tasks/index.php, bin/tasks/load.php, bin/tasks/operators.php, bin/tasks/query.php, bin/tasks/relationships.php, src/Database/PDO.php, tests/e2e/Adapter/Scopes/GeneralTests.php
Replaced use Utopia\CLI\Console with use Utopia\Console across CLI scripts, task runners, PDO wrapper, and tests.
Database tenant propagation & validation
src/Database/Database.php, src/Database/Validator/Structure.php
For shared tables with tenant-per-document: extract per-document $tenant, require tenant when needed, set internal '$tenant' field on documents before create/upsert; skip VAR_ID sequence validation for the internal "$tenant" attribute.
Tenant type narrowing & coercion
src/Database/Adapter.php, src/Database/Document.php, src/Database/Database.php
Narrowed tenant types from `int

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Database
    participant Adapter
    participant Document

    Client->>Database: createDocument(document)
    Note right of Database: Shared Tables + Tenant-per-Document
    Database->>Document: doc->getTenant()
    alt tenant is null and required
        Database-->>Client: throw missing tenant error
    else tenant present
        Database->>Document: set internal '$tenant' = (string)tenant
        Database->>Adapter: setTenant(string tenant)
        Database->>Adapter: persist document (includes '$tenant')
        Adapter-->>Database: persist result
        Database-->>Client: return created document
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • abnegate
  • eldadfux
  • fogelito

Poem

🐰 I nibbled through composer, found new paths to roam,

Console swapped its hat and tenants got a home.
Documents now wear strings, tidy and bright,
Shared tables hum together through day and night.
A rabbit's tiny cheer — code hopped into light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing the utopia-php/framework dependency with standalone packages (validators and console).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/remove-databases
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loks0n loks0n requested a review from abnegate March 13, 2026 15:42
loks0n and others added 2 commits March 13, 2026 16:03
CLI 0.22 no longer depends on utopia-php/framework, removing it
from the dependency tree entirely. Console moved to the standalone
utopia-php/console package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
setTenant() accepts int|string|null but PDO returns tenant as a string
after storage. The strict !== comparisons in getCollection() then fail
because (int)1 !== "1", causing "Collection not found" errors. The
Sequence validator also rejects integer tenant values since $tenant
has type VAR_ID which requires strings.

Cast tenant to string in Adapter::setTenant(), Document::getTenant(),
and the tenantPerDocument document paths. Skip Sequence validation for
$tenant since it's a user-provided identifier, not a sequence-generated
ID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loks0n loks0n force-pushed the chore/remove-databases branch from ac7da4f to a0b48ed Compare March 13, 2026 19:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Database/Document.php`:
- Around line 175-183: Update the docblock for the getTenant method to match its
native signature: change the `@return` annotation from "int|string|null" to
"string|null" so the PHPDoc aligns with the native return type declared on the
getTenant() method.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 128641c6-7a0d-4997-99bb-47a0e483f2e0

📥 Commits

Reviewing files that changed from the base of the PR and between ac7da4f and a0b48ed.

📒 Files selected for processing (4)
  • src/Database/Adapter.php
  • src/Database/Database.php
  • src/Database/Document.php
  • src/Database/Validator/Structure.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Database/Adapter.php
  • src/Database/Database.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants