PHPackages                             rmtram/text-database - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rmtram/text-database

ActiveLibrary

rmtram/text-database
====================

Text-file based database.

37PHP

Since Dec 22Pushed 10y ago2 watchersCompare

[ Source](https://github.com/Rmtram/TextDatabase)[ Packagist](https://packagist.org/packages/rmtram/text-database)[ RSS](/packages/rmtram-text-database/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

TextDatabase
============

[](#textdatabase)

[![Build Status](https://camo.githubusercontent.com/0046479a6bdf5692db87760e5a912cd3b505173506485540beb8f4bca8d771b3/68747470733a2f2f7472617669732d63692e6f72672f526d7472616d2f5465787444617461626173652e737667)](https://travis-ci.org/Rmtram/TextDatabase)

**Sorry!! the application has been creating does not work.**

Introduction
------------

[](#introduction)

Create Table.

```
use Rmtram\TextDatabase\Schema\Builder;
use Rmtram\TextDatabase\Schema\Schema;

require __DIR__ . '/vendor/autoload.php';

Rmtram\TextDatabase\Connection::setPath('path/to/');

Builder::make()
    ->table('users', function(Schema $schema) {
    $schema->integer('id')->autoIncrement()->primary();
    $schema->string('name')->notNull();
    $schema->dateTime('created_at');
    $schema->dateTime('updated_at');
});

Builder::make()
    ->table('posts', function(Schema $schema) {
    $schema->integer('id')->autoIncrement()->primary();
    $schema->string('title')->notNull();
    $schema->string('description')->notNull();
    $schema->integer('user_id');
    $schema->dateTime('created_at');
    $schema->dateTime('updated_at');
});

Builder::make()
    ->table('comments', function(Schema $schema) {
    $schema->integer('id')->autoIncrement()->primary();
    $schema->text('comment')->notNull();
    $schema->integer('post_id');
    $schema->dateTime('created_at');
    $schema->dateTime('updated_at');
});
```

Create EntityManager

```
class UserEntityManager extends BaseEntityManager
{
    /**
     * @var string
     */
    protected $table = 'users';

    /**
     * @var string
     */
    protected $entity = User::class;

    /**
     * @var array
     */
    protected $hasMany = [
        'posts' => Post::class
    ];

}

class PostEntityManager extends BaseEntityManager
{
    /**
     * @var string
     */
    protected $table  = 'posts';

    /**
     * @var string
     */
    protected $entity = Post::class;

    /**
     * @var array
     */
    protected $belongsTo = [
        'user' => User::class
    ];

    /**
     * @var array
     */
    protected $hasMany = [
        'comments' => Comment::class
    ];
}

class CommentEntityManager extends BaseEntityManager
{
    /**
     * @var string
     */
    protected $table  = 'comments';

    /**
     * @var string
     */
    protected $entity = Comment::class;

    /**
     * @var array
     */
    protected $belongsTo = [
        'post' => Post::class
    ];
}
```

Create Entity

```
class User extends BaseEntity
{
    /**
     * @var int
     */
    public $id;

    /**
     * @var string
     */
    public $name;

    /**
     * @var \DateTime|string
     */
    public $created_at;

    /**
     * @var \DateTime|string
     */
    public $updated_at;

    /**
     * @var string
     */
    protected static $entityManager = UserEntityManager::class;
}

class Post extends BaseEntity
{
    /**
     * @var int
     */
    public $id;

    /**
     * @var string
     */
    public $title;

    /**
     * @var string
     */
    public $description;

    /**
     * @var int
     */
    public $user_id;

    /**
     * @var \DateTime|string
     */
    public $created_at;

    /**
     * @var \DateTime|string
     */
    public $updated_at;

    /**
     * @var string
     */
    protected static $entityManager = PostEntityManager::class;
}

class Comment extends BaseEntity
{
    /**
     * @var int
     */
    public $id;

    /**
     * @var string
     */
    public $comment;

    /**
     * @var int
     */
    public $post_id;

    /**
     * @var string|\DateTime
     */
    public $created_at;

    /**
     * @var string|\DateTime
     */
    public $updated_at;

    /**
     * @var string
     */
    protected static $entityManager = CommentEntityManager::class;
}
```

### Create, Read, Update, Delete

[](#create-read-update-delete)

Create and Update.

```
// Create
$user = new User();
$user->name = 'NickName'
$user->created_at = new DateTime();
$user->updated_at = new DateTime();
UserEntityManager::save($user);

// Update
$user = new User();
$user->id = 1; // primary key.
$user->name = 'NickName'
$user->created_at = new DateTime();
$user->updated_at = new DateTime();
UserEntityManager::save($user);
```

Read.

```
$users = UserEntityManager::find()->all();
foreach ($users as $user) {
    echo $user->id;
    echo $user->name;
}

// sort
$users = UserEntityManager::find()
    ->order(['name' => 'asc'])
    ->all();

// relation
$user = UserEntityManager::find()->first();
foreach ($user->posts as $post) {
    echo $post->title;
    foreach ($post->comments as $comment) {
        echo $comment->comment;
        echo $comment->user->name;
    }
}
```

Delete.

```
// all
UserEntityManager::delete();

// where
$userRepository = new UserRepository();
UserEntityManager::delete(['id' => 1])

// entity
$user = UserEntityManager::find()->first();
UserEntityManager::delete($user);
```

###  Health Score

21

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d7cbad47788700bb6b0fe45e8431c751d6be5d4cb7806895140c9e38f3bd7b3?d=identicon)[Rmtram](/maintainers/Rmtram)

---

Top Contributors

[![NoguHiro](https://avatars.githubusercontent.com/u/4655005?v=4)](https://github.com/NoguHiro "NoguHiro (31 commits)")

### Embed Badge

![Health badge](/badges/rmtram-text-database/health.svg)

```
[![Health](https://phpackages.com/badges/rmtram-text-database/health.svg)](https://phpackages.com/packages/rmtram-text-database)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
