PHPackages                             devonblzx/wp-eloquent - 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. devonblzx/wp-eloquent

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

devonblzx/wp-eloquent
=====================

Eloquent ORM for WordPress, updated fork from tareq1988/wp-eloquent

5.3.x-dev(9y ago)1244GPLPHP

Since Oct 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/devonblzx/wp-eloquent)[ Packagist](https://packagist.org/packages/devonblzx/wp-eloquent)[ Docs](https://github.com/devonblzx/wp-eloquent)[ RSS](/packages/devonblzx-wp-eloquent/feed)WikiDiscussions master Synced yesterday

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

Eloquent Wrapper for WordPress
==============================

[](#eloquent-wrapper-for-wordpress)

This is a library package to use Laravel's [Eloquent ORM](http://laravel.com/docs/5.0/eloquent) with WordPress.

This is an updated fork from [tareq1988/wp-eloquent](https://github.com/tareq1988/wp-eloquent) that I intend to maintain and enhance.

Package Installation
--------------------

[](#package-installation)

To install this package, edit your `composer.json` file:

```
{
    "require": {
        "devonblzx/wp-eloquent": "dev-master"
    }
}
```

Now run:

`$ composer install`

Usage Example
=============

[](#usage-example)

Basic Usage
-----------

[](#basic-usage)

```
$db = \WeDevs\ORM\Eloquent\Database::instance();

var_dump( $db->table('users')->find(1) );
var_dump( $db->select('SELECT * FROM wp_users WHERE id = ?', [1]) );
var_dump( $db->table('users')->where('user_login', 'john')->first() );

// OR with DB facade
use \WeDevs\ORM\Eloquent\Facades\DB;

var_dump( DB::table('users')->find(1) );
var_dump( DB::select('SELECT * FROM wp_users WHERE id = ?', [1]) );
var_dump( DB::table('users')->where('user_login', 'john')->first() );
```

### Retrieving All Rows From A Table

[](#retrieving-all-rows-from-a-table)

```
$users = $db->table('users')->get();

foreach ($users as $user) {
    var_dump($user->display_name);
}
```

Here `users` is the table name **without prefix**. The prefix will be applied automatically.

### Other Examples

[](#other-examples)

- [Queries](http://laravel.com/docs/5.0/queries)
- [Eloquent ORM](http://laravel.com/docs/5.0/eloquent)

Writing a Model
---------------

[](#writing-a-model)

```
use \WeDevs\ORM\Eloquent\Model as Model;

class Employee extends Model {

}

var_dump( Employee::all()->toArray() ); // gets all employees
var_dump( Employee::find(1) ); // find employee with ID 1
```

The class name `Employee` will be translated into `PREFIX_employees` table to run queries. But as usual, you can override the table name.

### In-built Models for WordPress

[](#in-built-models-for-wordpress)

- Post
- Comment
- Post Meta
- User
- User Meta

```
use WeDevs\ORM\WP\Post as Post;

var_dump( Post::all() ); //returns only posts with WordPress post_type "post"
```

#### Filter `Post` by `post_status` and `post_type`

[](#filter-post-by-post_status-and-post_type)

```
use WeDevs\ORM\WP\Post as Post;
var_dump(Post::type('page')->get()->toArray()); // get pages
var_dump(Post::status('publish')->get()->toArray()); // get posts with publish status
var_dump(Post::type('page')->status('publish')->get()->toArray()); // get pages with publish status
```

How it Works
------------

[](#how-it-works)

- Eloquent is mainly used here as the query builder
- [WPDB](http://codex.wordpress.org/Class_Reference/wpdb) is used to run queries built by Eloquent
- Hence, we have the benfit to use plugins like `debug-bar` or `query-monitor` to get SQL query reporting.
- It doesn't create any extra MySQL connection

Minimum Requirement
-------------------

[](#minimum-requirement)

- PHP 5.3.0
- WordPress 3.6+

Author
------

[](#author)

[Tareq Hasan](http://tareq.wedevs.com)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.6% 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 ~0 days

Total

2

Last Release

3449d ago

### Community

Maintainers

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

---

Top Contributors

[![tareq1988](https://avatars.githubusercontent.com/u/153669?v=4)](https://github.com/tareq1988 "tareq1988 (24 commits)")[![sohelamin](https://avatars.githubusercontent.com/u/1708683?v=4)](https://github.com/sohelamin "sohelamin (5 commits)")[![dsge](https://avatars.githubusercontent.com/u/5737250?v=4)](https://github.com/dsge "dsge (3 commits)")[![monkeymonk](https://avatars.githubusercontent.com/u/574338?v=4)](https://github.com/monkeymonk "monkeymonk (2 commits)")[![sabbir1991](https://avatars.githubusercontent.com/u/2692939?v=4)](https://github.com/sabbir1991 "sabbir1991 (1 commits)")

---

Tags

pluginwordpressormsqleloquent

### Embed Badge

![Health badge](/badges/devonblzx-wp-eloquent/health.svg)

```
[![Health](https://phpackages.com/badges/devonblzx-wp-eloquent/health.svg)](https://phpackages.com/packages/devonblzx-wp-eloquent)
```

###  Alternatives

[tareq1988/wp-eloquent

Eloquent ORM for WordPress

56954.9k](/packages/tareq1988-wp-eloquent)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[dbout/wp-orm

WordPress ORM with Eloquent.

12910.2k1](/packages/dbout-wp-orm)

PHPackages © 2026

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