PHPackages                             peopleandpixel/ppentity - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. peopleandpixel/ppentity

ActiveProject[Utility &amp; Helpers](/categories/utility)

peopleandpixel/ppentity
=======================

Basic entity class.

1.0.3(6mo ago)02GPL-3.0-or-laterPHPPHP &gt;=8.3CI passing

Since Oct 30Pushed 6mo agoCompare

[ Source](https://github.com/peopleandpixel/ppentity)[ Packagist](https://packagist.org/packages/peopleandpixel/ppentity)[ RSS](/packages/peopleandpixel-ppentity/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

ppentity
========

[](#ppentity)

A tiny helper around RedBeanPHP to work with very simple, dynamic entities and lists.

It gives you:

- `ppEntity\BasicEntity` — create, load, change, and save an entity in a table (bean) named by you.
- `ppEntity\List\BasicList` — fetch all entities or find by a condition.
- `ppEntity\DB\DBClass` — minimal DB bootstrap using a `.env` file.

The library is intentionally small. The public API is demonstrated in the tests and the examples below.

Requirements
------------

[](#requirements)

- PHP 8.3+
- PDO extension (and the driver for your DB)

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

[](#installation)

```
composer require peopleandpixel/ppentity
```

Autoloading uses PSR-4 (`ppEntity\\` → `src/`).

Configuration (.env)
--------------------

[](#configuration-env)

Connections are configured through environment variables loaded from a `.env` file in the project root (same folder as `src/`). The following variables are read by `DBClass`:

- `DB_TYPE` — one of: `sqlite`, `mysql`, `mariadb`, `postgresql`, `cubrid`

Depending on the type:

SQLite

- `DB_PATH` — path to the SQLite file (e.g. `data/app.sqlite`)

MySQL/MariaDB

- `DB_HOST` — hostname
- `DB_PORT` — port
- `DB_NAME` — database name
- `DB_USERNAME` — user
- `DB_PASSWORD` — password

PostgreSQL

- `DB_HOST` — hostname
- `DB_NAME` — database name
- `DB_USERNAME` — user
- `DB_PASSWORD` — password

Cubrid

- `DB_HOST` — hostname
- `DB_NAME` — database name
- `DB_USERNAME` — user
- `DB_PASSWORD` — password

There is an example file you can copy:

```
cp .env.example .env
# then adjust values
```

Quick start
-----------

[](#quick-start)

Below mirrors what the tests do. It uses a bean/table named `test` and two dynamic fields: `value1` and `value2`.

```
