PHPackages                             elhardoum/meta-php - 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. elhardoum/meta-php

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

elhardoum/meta-php
==================

Makes it easier saving meta data into the database, inspired by WordPress meta (users, options, posts, etc.)

1.0(8y ago)053GPL-2.0PHPPHP &gt;=5.3.0

Since Jul 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/elhardoum/meta-php)[ Packagist](https://packagist.org/packages/elhardoum/meta-php)[ RSS](/packages/elhardoum-meta-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Meta data PHP
=============

[](#meta-data-php)

Makes it easier saving meta data into the database, inspired by WordPress meta (users, options, posts, etc.)

About
-----

[](#about)

This helper class allows you to save custom meta data into the database, and makes manipulating and retrieving these data quite easier, and the performance is a bonus.

By default, once you update a meta, or retrieve it for the first time, it is stored into a global variable to avoid multiple queries.

From my setup, I have Redis configured and it's easier to cache these meta for performance that rocks.

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

[](#installation)

1. Require the package with composer:

`composer require "elhardoum/meta-php:*@dev"`

2. Create the `meta` table:

```
create table if not exists meta (
  `object_id` bigint(20) default 0,
  `meta_key` varchar(255) not null,
  `meta_value` LONGTEXT not null,
  primary key(meta_key, object_id)
);
```

3. Define the database credentials, and include the `loader.php` file into your setup

```
defined ( 'DB_HOST' ) || define ( 'DB_HOST', '' );
defined ( 'DB_NAME' ) || define ( 'DB_NAME', '' );
defined ( 'DB_USER' ) || define ( 'DB_USER', '' );
defined ( 'DB_PASS' ) || define ( 'DB_PASS', '' );

include '/path/to/meta-php/Src/loader.php';
```

4. Now enjoy the API!

API
---

[](#api)

You can basically store any type of object using follows API. The data is serialized before saving and unserialized after retrieving. No data sanitization or escaping required, PDO handles that for you.

This repository ships with the default metadata functions on the global namespace. Here's some use:

1. Options

```
// get
get_option( $option_name, $default_value=null );

// update
update_option( $option_name, $option_value );

// delete
delete_option( $option_name );

// delete all
delete_all_options();
```

2. User Meta

```
// get
get_user_meta( $user_id, $meta_key, $default_value=null );

// update
update_user_meta( $user_id, $meta_key, $meta_value );

// delete
delete_user_meta( $user_id, $meta_key );

// delete all
delete_all_user_meta( $user_id );
```

3. Post Meta

```
// get
get_post_meta( $post_id, $meta_key, $default_value=null );

// update
update_post_meta( $post_id, $meta_key, $meta_value );

// delete
delete_post_meta( $post_id, $meta_key );

// delete all
delete_all_post_meta( $post_id );
```

You are free to create a custom group and use it.

To use the class `Meta` (`MetaPHP\Meta`), make sure also the database class `Database` (same namespace) is included as well.

```
use MetaPHP\Meta;

$Meta = Meta::instance(true);
$Meta->group('custom'); // set a custom group for the meta

$Meta->get(
  $key, // meta key
  $object_id, // if required, like in users, posts (the ID) defaults to null,
  $default_value=null // a default value to be returned, not required
);

$Meta->update(
  $key, // meta key
  $value, // a value
  $object_id=null // if required, like in users, posts (the ID) defaults to null,
);

$Meta->delete(
  $key, // meta key
  $object_id=null // if required, like in users, posts (the ID) defaults to null,
);
```

... more to come.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3263d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7893147?v=4)[elhardoum](/maintainers/elhardoum)[@elhardoum](https://github.com/elhardoum)

---

Top Contributors

[![elhardoum](https://avatars.githubusercontent.com/u/7893147?v=4)](https://github.com/elhardoum "elhardoum (19 commits)")

### Embed Badge

![Health badge](/badges/elhardoum-meta-php/health.svg)

```
[![Health](https://phpackages.com/badges/elhardoum-meta-php/health.svg)](https://phpackages.com/packages/elhardoum-meta-php)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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