PHPackages                             thomas-squall/efxphp - 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. thomas-squall/efxphp

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

thomas-squall/efxphp
====================

MySQL Entity Framework for PHP

0.1.0(5y ago)04MITPHP

Since Nov 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ThomasSquall/EFxPHP)[ Packagist](https://packagist.org/packages/thomas-squall/efxphp)[ RSS](/packages/thomas-squall-efxphp/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

Entity Framework for PHP/MySQL
==============================

[](#entity-framework-for-phpmysql)

This is an Entity Framework for PHP based on MySQL.

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

[](#installation)

Using composer is quite simple, just run the following command:

```
$ composer require thomas-squall/efxphp
```

Prerequisites
-------------

[](#prerequisites)

Before using this library you should make sure to have installed PHP7.1 or major.

Usage
-----

[](#usage)

At first, you need to connect to the database.

The parameter to pass are:

- $host = The URL to the server where the database is running (localhost for local databases)
- $username = The username to login into MySQL
- $password = The password to login into MySQL
- $database = The database name to connect to

For more information see the link:

This is how you instantiate a new Adapter:

```
use EFxPHP\Adapter;

// Enstablish a connection.
$adapter = new Adapter();
$adapter->connect($host, $username, $password, $database);
```

Now you have to create a model

```
/**
 * @Model(name = "people")
 */
class person {
    /**
     * @Type(type = "varchar", length = 16)
     * @var string $name
     */
    public $name;

    /**
     * @Type(type = "int")
     * @var int $age
     */
    public $age;

    /**
     * @Type(type = "varchar", length = 10)
     * @Default(value = "italian")
     * @var string $nationality
     */
    public $nationality;
}
```

And register it

```
$db->registerModel(new person());
```

If you want to create/update your tables automatically based on your model, pass true as second parameter in the registerModel method

```
/*
 * Note that this will:
 * 1. Create the table if it does not exist
 * 2. Add new columns if you added new parameters to the model
 * 3. Remove unused columns if you deleted parameters from the model
 *
 * Specially for point 3, use it with care.
*/
$db->registerModel(new person(), true);
```

### Find

[](#find)

Once connected to the database we can simply query for the collection we want:

```
$items = $adapter->find('people');
```

You can also filter your query:

```
use MongDriver\Filter;

$filters =
[
    new Filter('age', 29, Filter::IS_EQUALS),
    new Filter('nationality', ['italian', 'spanish'], Filters::IS_IN_ARRAY)
];

$items = $adapter->find('people', $filters);
```

### Insert

[](#insert)

If you want to insert an item you have simply to pass an instance of a registered model:

```
$item = new Person();
$item->name = 'Thomas';
$item->surname = 'Cocchiara');

$adapter->insert($item);
```

Hope you guys find this library useful.

Please share it and give me a feedback :)

Thomas

###  Health Score

20

—

LowBetter than 17% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

1959d ago

### Community

Maintainers

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

---

Top Contributors

[![ThomasSquall](https://avatars.githubusercontent.com/u/7748020?v=4)](https://github.com/ThomasSquall "ThomasSquall (5 commits)")

### Embed Badge

![Health badge](/badges/thomas-squall-efxphp/health.svg)

```
[![Health](https://phpackages.com/badges/thomas-squall-efxphp/health.svg)](https://phpackages.com/packages/thomas-squall-efxphp)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k280.5M5.5k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k114.4M86](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k51.5M8.1k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k62.7M487](/packages/mongodb-mongodb)[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k22.1M345](/packages/spatie-laravel-translatable)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.5k23.2M24](/packages/kirschbaum-development-eloquent-power-joins)

PHPackages © 2026

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