Lightweight PHP ORM
PHersist is a minimalistic ORM library for PHP that generates model classes backed by database tables. Work with objects naturally and commit changes to the database when you're done - PHersist handles the SQL for you.
Why PHersist?
Small but Powerful
Minimalistic codebase with no external dependencies, yet offers robust mapping for objects, relations, and maps.
Schema Flexibility
Works with existing normalized database schemas or generates new ones alongside your model classes.
Easy to Use
Intuitive API for creating, retrieving, updating, and deleting records with simple object-oriented syntax.
Advanced Features
Includes ObjectCache, soft delete behavior, and trait-based class extension for runtime optimization.
Quick Examples
Creating a new user
$user = new User();
$user->email = 'joe@example.org';
$user->password = password_hash('secret', PASSWORD_DEFAULT);
$user->name = 'Joe Example';
$user->commit();
echo "User created: {$user->name}\n";
Finding users
use PHersist\ObjectFinder;
$user = ObjectFinder::create(User::class)
->where('email', '=', 'joe@example.org')
->fetchOne();
echo "User retrieved: {$user->name}\n";