Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Database Factory for PHP Unit Tests
Latest commit 054cac8 @jimbojsb jimbojsb Merge pull request #40 from sometechie/next
Stop using deprecated parameter
Failed to load latest commit information.
lib Merge pull request #40 from sometechie/next
tests Recursively apply eval for sequences
.gitignore Converted Phactory to use PHP namespaces and instance objects
AUTHORS add changelog, readme, and authors files
LICENSE add license file Bumping required version of PHP
VERSION up version to 0.3.2
composer.json Updating composer.json to include Lumbendil's changes:

Phactory: PHP Database Object Factory for Unit Testing

What is it?

Phactory is an alternative to using database fixtures in your PHP unit tests. Instead of maintaining a separate XML file of data, you define a blueprint for each table, and then create as many different objects as you need.

Phactory was inspired by Factory Girl.


  • Define default values for your table rows once with Phactory::define(), then easily create objects in that table with a call to Phactory::create().
  • Create associations between your defined tables, and the objects will automatically be associated in the database upon creation.
  • Use sequences to create unique values for each successive object you create.

Database Support

  • MySQL
  • Sqlite
  • Postgresql

Language Support

  • PHP >= 5.3


  • Each table must have a single integer primary key for associations to work.
Something went wrong with that request. Please try again.