PHPackages                             simple-as-fuck/orm - 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. [Database &amp; ORM](/categories/database)
4. /
5. simple-as-fuck/orm

ActiveLibrary[Database &amp; ORM](/categories/database)

simple-as-fuck/orm
==================

Simple orm with class generation.

0.3.0(2mo ago)046UnlicensePHPPHP ^7.4|^8.0CI failing

Since Dec 7Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/simple-as-fuck/orm)[ Packagist](https://packagist.org/packages/simple-as-fuck/orm)[ RSS](/packages/simple-as-fuck-orm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (7)Used By (0)

Simple as fuck / orm
====================

[](#simple-as-fuck--orm)

Orm layer easy to use with customizable class generation.

Installation
------------

[](#installation)

```
composer require simple-as-fuck/orm
```

### Usage generator with mysql as composer command

[](#usage-generator-with-mysql-as-composer-command)

Add configurations into your composer.json extra ().

All configuration keys are commented in [Defaults\\Config](../src/Config/Defaults/Config.php) and can be change in composer extra.

```
{
    "extra": {
        "orm-generator-config": {
            "mysql-host": "127.0.0.1",
            "mysql-port": 3306,
            "mysql-username": "root",
            "mysql-password": "",
            "mysql-database-name": "database"
        }
    }
}
```

Add commands into your composer.json scripts ().

```
{
    "scripts": {
        "orm:generate": "SimpleAsFuck\\Orm\\Generator\\Command\\Composer::mysqlGenerate",
        "orm:check": "SimpleAsFuck\\Orm\\Generator\\Command\\Composer::mysqlCheck"
    }
}
```

After prepared composer you can run commands:

```
composer orm:generate
```

Command generate for all database tables with primary key Model and Repository classes. By default, models are in App\\Model\\Database and repository in App\\Service\\Database namespace.

```
composer orm:check
```

If you add all generated classes into repository, you can check generated content if is up-to-date with database structure.

```
composer orm:generate --no-interaction --no-dev
```

Is recommended avoid adding generated code in repository and run orm generation like this for production deploy after composer install. **--no-dev** option in default class templates remove some comments from generated code and some additional checks with exception, this can make orm gently faster.

```
composer orm:generate -- --i-am-not-stupid
```

**-- --i-am-not-stupid** and **--no-dev** are synonyms because if you write production deploy script, is good to know what you doing and not be stupid :-).

### Usage default generated classes

[](#usage-default-generated-classes)

Nice after successful class generation with default templates, you can write code like this.

```
/**
 * you can put some implementation of abstract connection in your DI container
 * than all repository can be loaded from DI
 *
 * @var \SimpleAsFuck\Orm\Database\Abstracts\Connection $connection
 */
$repository = new \App\Service\Database\SomethingRepository($connection);

$model = new \App\Model\Database\Something('example', 5);

$repository->insert($model);

$autoIncrementPrimaryKey = 1;
$insertedModel = new \App\Model\Database\Something('update_example', 5, $autoIncrementPrimaryKey);

$repository->update($insertedModel);

$insertedModel = $repository->selectByPrimaryKey($autoIncrementPrimaryKey);

$repository->delete($insertedModel);
```

Customization
-------------

[](#customization)

### Usage generator with mysql as php class

[](#usage-generator-with-mysql-as-php-class)

If you want write in application your command for class generation, mainly for configuration sharing with generator and app, use class **\\SimpleAsFuck\\Orm\\Generator\\Generator**.

```
/**
 * abstraction with configuration you can create some adapter for config from your app
 *
 * @var \SimpleAsFuck\Orm\Config\Abstracts\Config $config
 */

/**
 * you can inject custom connection into mysql database
 *
 * @var \SimpleAsFuck\Orm\Database\Mysql\Connection|null $connection
 */

/**
 * you can inject custom directory generator and change what classes will generated
 * by default models and repositories are generated with model-*, repository-* config.
 *
 * @var \SimpleAsFuck\Orm\Generator\Abstracts\DirectoryGenerator|null $directoryGenerator
 */

$generator = \SimpleAsFuck\Orm\Generator\Generator::createMysql($config, $connection, $directoryGenerator);

// same as composer cmd "composer orm:generate"
$generator->generate();
// same as composer cmd "composer orm:check"
$generator->check();
// same as composer cmd "composer orm:generate -- --i-am-not-stupid"
$generator->generate(false);
```

### Usage generator with different database type

[](#usage-generator-with-different-database-type)

Generator can create classes from various sources, because use abstract **SimpleAsFuck\\Orm\\Generator\\Abstracts\\StructureLoader**. You can load models structure from any source and create any classes.

```
/**
 * you must inject some structure loader and provide ModelStructure array,
 * for every instance of ModelStructure should be created some class or classes in $directoryGenerator
 * $generator instance will handle file system synchronization
 *
 * @var \SimpleAsFuck\Orm\Generator\Abstracts\StructureLoader $structureLoader
 */

/**
 * you must inject directory generator with definition
 * which classes will generated based on ModelStructure array
 *
 * @var \SimpleAsFuck\Orm\Generator\Abstracts\DirectoryGenerator $directoryGenerator
 */

$generator = new \SimpleAsFuck\Orm\Generator\Generator($structureLoader, $directoryGenerator);
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance86

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~382 days

Recently: every ~477 days

Total

6

Last Release

69d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.2.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/dcf2ca03f52f05685f62127eaeb513e84856c4cbbdc728fb0eb99d6e659a7a37?d=identicon)[Triplkrypl](/maintainers/Triplkrypl)

---

Top Contributors

[![Triplkrypl](https://avatars.githubusercontent.com/u/15320684?v=4)](https://github.com/Triplkrypl "Triplkrypl (74 commits)")

---

Tags

generatormysqlormphpsimple

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/simple-as-fuck-orm/health.svg)

```
[![Health](https://phpackages.com/badges/simple-as-fuck-orm/health.svg)](https://phpackages.com/packages/simple-as-fuck-orm)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M186](/packages/spatie-laravel-backup)[spatie/laravel-db-snapshots

Quickly dump and load databases

1.2k2.8M20](/packages/spatie-laravel-db-snapshots)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M262](/packages/ssch-typo3-rector)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[forkcms/forkcms

Fork is an open source CMS that will rock your world.

1.2k44.5k](/packages/forkcms-forkcms)

PHPackages © 2026

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