PHPackages                             worksome/foggy - 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. worksome/foggy

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

worksome/foggy
==============

Foggy is a tool for making database dumps with some data removed/changed.

v0.6.6(4mo ago)26601.5k↑51.2%1[1 PRs](https://github.com/worksome/foggy/pulls)1MITPHPPHP ^8.4CI passing

Since Oct 23Pushed 2w ago11 watchersCompare

[ Source](https://github.com/worksome/foggy)[ Packagist](https://packagist.org/packages/worksome/foggy)[ RSS](/packages/worksome-foggy/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (17)Versions (23)Used By (1)

Foggy - Database scrubbing
==========================

[](#foggy---database-scrubbing)

Foggy is a package which creates a database dump of your database, but with scrubbed data. Perfect for taking a production database and use locally.

Install
-------

[](#install)

For installation via Composer

```
composer require worksome/foggy
```

For installation in a Laravel application

```
composer require worksome/foggy-laravel
```

Usage
-----

[](#usage)

For usage with Laravel, read more in [Laravel Foggy docs](https://github.com/worksome/foggy-laravel#usage).

Configuration
-------------

[](#configuration)

The configuration lies in a JSON file, which has to adhere to the [`schema.json`](schema.json) file. You can validate your configuration file on [jsonschemavalidator.net](https://www.jsonschemavalidator.net) or directly in an IDE such as PhpStorm.

For the most basic configuration, where all tables are dumped, but no data is scrubbed, we simply do:

```
{
  "database": {
    "*": {
      "withData": true
    }
  }
}
```

Here we have specified that all tables and views (`*`) should be dumped with data by default. A more secure default would be to set `withData` to `false`, so only schema definitions are exported, if nothing specific is specified.

### Defining rules for a table

[](#defining-rules-for-a-table)

All table definitions live inside `database` key in the JSON object. Each table can have an array of rules. A rule consists of the following:

- `column` - Which column to apply the rule to.
- `type` - Which rule type to use.
- `value` - The value supplied to the rule type.
- `times` (optional) - The number of times this rule is allowed to be applied.
- `params` (optional) - A list of static parameters supplied to the rule.
- `condition` (optional) - Add a condition which has to pass before the rule is applied.

In the following snippet we have added some rules for the `users` table. It shows a quick example of some rules and parameters.

```
{
  "database": {
    "users": {
      "withData": true,
      "rules": [
        {
          "$comment": "Generate a fake name for all users, except if they are our own employees",
          "column": "name",
          "type": "faker",
          "value": "name",
          "condition": "!str_contains($row['email'], '@worksome.com')"
        },
        {
          "$comment": "Replace all avatars with a fake image based on their user id.",
          "column": "avatar",
          "type": "php",
          "value": "\"https://api.adorable.io/avatars/285/{$row['id']}.png\""
        },
        {
          "$comment": "Replace all passwords with `secret`",
          "column": "password",
          "type": "replace",
          "value": "$2y$10$xmVOYC1DUte0oG86Zz8oeeKc3UXZNrdSKMoZGrCElup6VexStFh22"
        }
      ]
    }
  }
}
```

### Rules

[](#rules)

Each table can have an array of rules. Rules are applied to a specific column and can modify the values in that column per row.

#### Faker

[](#faker)

The `faker` rule is to replace the value with a new fake value. It uses the [faker library](https://github.com/fzaninotto/Faker) underneath, so all formatters available in faker can be used here.

For calling a simple faker property, simply specify `value` as the property you want to use. In the following example we are calling the `email` faker.

```
{
  "column": "some_column",
  "type": "faker",
  "value": "email"
}
```

Sometimes you might want to use Faker formatters that take arguments. Arguments can be supplied by using the `params` key in the JSON object. In the following example we specify that we only want to generate `male` names.

```
{
  "column": "some_column",
  "type": "faker",
  "value": "firstName",
  "params": "male"
}
```

#### Replacer

[](#replacer)

The replacer rule replaces a column with the given value. It's a simple rule for when you just want all entries to have the same value. A great use-case is for setting all passwords to the same value, so when using the scrubbed database, you can log in on all users with the same password. In the following example we replace all passwords with `secret`, but a hashed edition of it.

```
{
  "column": "password",
  "type": "replace",
  "value": "$2y$10$xmVOYC1DUte0oG86Zz8oeeKc3UXZNrdSKMoZGrCElup6VexStFh22"
}
```

#### PHP

[](#php)

The PHP rule is a basic, but really powerful rule. It allows you to define a PHP string which will be applied to the column. This string has a few variables which can be accessed.

- `value` - this variable will hold the current value of the column which the rule should be applied to.
- `row` - This variable will hold the current values of the whole row which the rule should be applied to.

The PHP string will be evaluated, and the value returned from it will be the new value of the column. It is not needed to write `return`, as the statement is wrapped in a `return` automatically.

```
{
  "column": "ip",
  "type": "php",
  "value": "sha1($value)"
}
```

### Conditions

[](#conditions)

#### Times

[](#times)

It is possible to limit a column to only be applied `x` amount of times, by supplying an argument named `times`. This will limit, so the rule is only applied until the `times` are hit.

### SQL Views

[](#sql-views)

All views definitions live inside `database` key in the JSON object. In opposition to tables, views do not have any particular rules applicable to them.

The only requirement is for them to be listed in the JSON object to be included in the import. The wildcard configuration `*` will include them all.

```
{
  "database": {
      "stock_quantity_view": {}
  }
}
```

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

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

Every ~122 days

Recently: every ~94 days

Total

17

Last Release

124d ago

PHP version history (5 changes)v0.1.0PHP &gt;=7.4

V0.2.2PHP ^7.4|^8.0

v0.6.0PHP ^8.2

v0.6.3PHP ^8.3

v0.6.6PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1899334?v=4)[Owen Voke](/maintainers/owenvoke)[@owenvoke](https://github.com/owenvoke)

![](https://avatars.githubusercontent.com/u/5870441?v=4)[Oliver Nybroe](/maintainers/olivernybroe)[@olivernybroe](https://github.com/olivernybroe)

---

Top Contributors

[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (35 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![jeremynikolic](https://avatars.githubusercontent.com/u/4478969?v=4)](https://github.com/jeremynikolic "jeremynikolic (2 commits)")[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/worksome-foggy/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

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