Myxa logo

Myxa

Version: 1.0.6

A lightweight, AI-powered PHP framework for teams that want to build modern systems fast without giving up clarity, performance, or developer joy.

Myxa is designed around recent PHP practices: strict typing, explicit structure, container-driven architecture, fast backend execution, and a developer experience that feels approachable whether you stay server-rendered or grow into a hybrid frontend.

Documentation

Mongo Models

The framework includes MongoModel for document-backed models.

Use SQL Model when you are working with relational tables.

Use MongoModel when you want declared-property models backed by Mongo-style collections instead of SQL tables.

Basic Model

use Myxa\Mongo\MongoModel;

final class UserDocument extends MongoModel
{
    protected string $collection = 'users';

    // Mongo uses _id by default.
    protected string|int|null $_id = null;

    protected string $email = '';
    protected string $status = '';
}

The same strict declared-property idea still applies:

  • document fields should be declared as real properties
  • unknown attributes are rejected during normal writes
  • guarded, hidden, internal, and cast attributes still apply
  • built-in casts currently include DateTime, DateTimeImmutable, and Json

Typical Usage

UserDocument::setManager($mongoManager);

$user = UserDocument::create([
    'email' => 'john@example.com',
    'status' => 'active',
]);

$found = UserDocument::find($user->getKey());
$found->status = 'inactive';
$found->save();

Differences From SQL Models

  • MongoModel is document-backed
  • it does not use the SQL query builder
  • it does not provide SQL-style relations like hasMany() or belongsTo()

Connection support today:

  • MongoManager resolves named Mongo connections
  • each MongoConnection resolves named collections
  • the built-in collection implementation currently shipped by the framework is InMemoryMongoCollection
  • custom collection backends can be added by implementing MongoCollectionInterface

So at the moment, Mongo support is best described as:

  • a document-model layer with a connection/collection abstraction
  • built-in in-memory support for tests and local experiments
  • room for custom adapters when you want a real external Mongo backend

This project does not scaffold Mongo connections yet, so treat this as a framework capability you can wire in when your app needs document storage.

Further Reading