PHPackages                             mauris/samsui - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. mauris/samsui

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

mauris/samsui
=============

Samsui is a factory library for building PHP objects useful for setting up test data in your applications.

1.0.0(12y ago)31553BSD-3-ClausePHPPHP &gt;=5.3.0

Since Nov 3Pushed 11y ago2 watchersCompare

[ Source](https://github.com/mauris/samsui)[ Packagist](https://packagist.org/packages/mauris/samsui)[ RSS](/packages/mauris-samsui/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

\#Samsui

[![Build Status](https://camo.githubusercontent.com/22aec94778d9a428fc734590164d53d45a4f1404223008a1c22b7ccf5ec9a4d4/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6d61757269732f73616d7375692e737667)](https://travis-ci.org/mauris/samsui) [![Latest Stable Version](https://camo.githubusercontent.com/4a668a9aa4cdb5cbf0e45a4d7f44e4555a07a5dfcacbaf00728f010617dd746a/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61757269732f73616d7375692e737667)](https://packagist.org/packages/mauris/samsui) [![Total Downloads](https://camo.githubusercontent.com/b882f4f9231b8253eb3d8cfeccf2a66b6ebca411571f301ba32b8b60bf692183/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d61757269732f73616d7375692e737667)](https://packagist.org/packages/mauris/samsui) [![](https://camo.githubusercontent.com/a3cad7452b4c4a0d6dd58d730b45a5b3c3d5900bb862fe464d27fca63597eee0/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d425344253230332d2d436c617573652d627269676874677265656e2e737667)](license.md) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/5450172eb7f86e29085902e2b31793ce0368ea2e81802abf1cfdb83f6e4c3d0b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d61757269732f73616d7375692f6261646765732f7175616c6974792d73636f72652e706e673f733d36623232303533353362653431393064343864376261333964626638663037326437386537366365)](https://scrutinizer-ci.com/g/mauris/samsui/) [![Code Coverage](https://camo.githubusercontent.com/b1db9077d1e9c3e057355885f95370d9009ae849945730ecf74f1fad6e2607f4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d61757269732f73616d7375692f6261646765732f636f7665726167652e706e673f733d34363438393261653665646631636536363762376431316165306662333231366263333334373064)](https://scrutinizer-ci.com/g/mauris/samsui/)

Samsui is a factory library for building PHP objects useful for setting up test data in your applications. It is mainly inspired by [Rosie](https://github.com/bkeepers/rosie) for JavaScript and [factory\_girl](https://github.com/thoughtbot/factory_girl) for Ruby.

> [Samsui women](https://en.wikipedia.org/wiki/Samsui_women) refers to a group of Chinese immigrants who came to Singapore to work in construction and industries. Their hardwork contributed to Singapore's development as a colony and young nation.

With Samsui, you can quickly build prototype application and generate as many data as you need for testing your prototype.

- Samsui was created by and maintained by [Sam Yong](https://github.com/mauris).
- Samsui uses [Travis CI](https://travis-ci.org/mauris/samsui) to check that the code works.
- Samsui uses \[Scrutinizer CI\] to check code quality and test coverage.
- Samsui uses [Composer](https://getcomposer.org/) to load and manage its dependencies.
- Samsui is licensed under the [BSD 3-Clause](license.md) license.

\##Installation

Samsui is a PHP library that manages its dependencies using [Composer](http://getcomposer.org). You can directly use [Samsui](https://packagist.org/packages/mauris/samsui/) in your application through Composer:

```
{
    "require": {
      "mauris/samsui": "1.0.*"
    }
}

```

Then just run Composer:

```
$ php composer.phar install

```

\##Usage

You can provide definition of your objects to Samsui:

```
use Samsui\Factory;

$factory = new Factory();

// define an object quickly
$factory->define('person')
	->sequence('personId')
	->attr('firstName', 'James')
    ->attr('lastName', 'Clark')
    ->attr('email', function ($i, $o) {
        return strtolower($o->firstName . '.' . $o->lastName . '@example.com');
    })
	->attr('createdTime', function () {
		return time();
	});

```

You can build one at a time, or hundreds of them on the go!

```
// build them on the go!
$person = $factory->build('person');

// or build many!~
$people = $factory->build('person', 500);

```

The output of a person object would be (well, after JSON encoding):

```
{
    "personId": "1",
    "firstName": "James",
    "lastName": "Clark",
    "email": "james.clark@example.com",
    "createdTime": "1383465074"
}

```

You can also use Samsui's fake data generator to fill your objects with real variety and randomity:

```
use Samsui\Factory;
use Samsui\Generator\Generator;

$factory = new Factory();

// define an object quickly
$factory->define('person')
    ->sequence('personId')
    ->attr('firstName', Generator::person()->firstName)
    ->attr('lastName', Generator::person()->lastName)
    ->attr('email', function ($i, $o) {
        return Generator::email()->emailAddress(
            array(
                'firstName' => $o->firstName,
                'lastName' => $o->lastName,
                'domains' => array(
                    'hotmail.com',
                    'gmail.com',
                    'example.com'
                )
            )
        );
    })
    ->attr('createdTime', function () {
        return time();
    });

```

\##Upcoming

- Generation of data based on locale (location+language)
- Implementation of Data Generators for use with attributes
    - Names (different locale)
    - Email addresses
    - Addresses and Postal Codes
    - Age (based on age groups defined)
    - Gender (with Natural Birth Ratio)
    - IP Address v4 and v6
    - URLs
    - Lorem Ipsum text
    - Date/Times (based on range or sequence)
    - Hash functions output (SHA-1, SHA-256 etc.)
    - GPS latitude / longitude, land coordiates
    - Handphone numbers
    - Colors (RGB array, Hexadecimal)
    - Images (Avatar, Sized)
- Improved JSON reader
- Generation of Factory definitions to PHP classes directly

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 98.9% 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

4622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1743cee8bb3242229368d7fca5a7ac952932fd377d0c3d4343eb8dceea6a395e?d=identicon)[mauris](/maintainers/mauris)

---

Top Contributors

[![mauris](https://avatars.githubusercontent.com/u/996939?v=4)](https://github.com/mauris "mauris (281 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![JeanAzzopardi](https://avatars.githubusercontent.com/u/5838?v=4)](https://github.com/JeanAzzopardi "JeanAzzopardi (1 commits)")

### Embed Badge

![Health badge](/badges/mauris-samsui/health.svg)

```
[![Health](https://phpackages.com/badges/mauris-samsui/health.svg)](https://phpackages.com/packages/mauris-samsui)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M341](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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