diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a4da8ba..2ffb4e8 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,16 +8,16 @@ on:
jobs:
php-tests:
- name: Testing on PHP${{ matrix.php }}
+ name: Testing on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
matrix:
- php: ['8.2']
+ php: [8.2, 8.3]
fail-fast: false
steps:
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
diff --git a/README.md b/README.md
index 883b39f..a91504b 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# 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.
-## Installation
+## Install
+
For installation via composer
````bash
$ composer require worksome/foggy
@@ -14,14 +16,16 @@ $ composer require worksome/foggy-laravel
```
## Usage
-For usage with Laravel, read more in [Laravel Foggy docs](https://github.com/worksome/foggy-laravel#usage).
+For usage with Laravel, read more in [Laravel Foggy docs](https://github.com/worksome/foggy-laravel#usage).
## Configuration
+
The configuration lies in a JSON file, which has to adhere to the `schema.json` file.
You can validate your configuration file on [jsonschemavalidator.net](https://www.jsonschemavalidator.net/) or directly in phpstorm.
-For the most basic configuration, where all tables are dumped, but no data is scrubbed, we simply do
+For the most basic configuration, where all tables are dumped, but no data is scrubbed, we simply do:
+
```json
{
"database": {
@@ -31,10 +35,12 @@ For the most basic configuration, where all tables are dumped, but no data is sc
}
}
```
+
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
+
All table definitions live inside `database` key in the json object.
Each table can have an array of rules. A rule consist of the following
- `column` - Which column to apply the rule to.
@@ -46,6 +52,7 @@ Each table can have an array of rules. A rule consist of the following
In the following snippet we have added some rules for the `users` table.
It shows a quick example of some rules and parameters.
+
```json
{
"database": {
@@ -78,10 +85,12 @@ It shows a quick example of some rules and parameters.
```
### 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
+
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.
@@ -111,6 +120,7 @@ In the following example we specify that we only want to generate `female` names
```
#### 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 user's
@@ -126,6 +136,7 @@ In the following example we replace all passwords with `secret`, but a hashed ed
```
#### 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.
@@ -146,10 +157,12 @@ not needed to write `return`, as the statement is wrapped in a `return` automati
### Conditions
#### 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
+
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.
diff --git a/composer.json b/composer.json
index b91c538..6c95d1d 100644
--- a/composer.json
+++ b/composer.json
@@ -15,17 +15,17 @@
"php": "^8.2",
"ext-json": "*",
"ext-pdo": "*",
- "doctrine/dbal": "^3.1",
- "symfony/console": "^6.2",
- "symfony/var-dumper": "^6.2",
- "thecodingmachine/safe": "^2.0",
+ "doctrine/dbal": "^3.6",
+ "symfony/console": "^6.4 || ^7.0",
+ "symfony/var-dumper": "^6.4 || ^7.0",
+ "thecodingmachine/safe": "^2.5",
"fakerphp/faker": "^1.10"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
- "pestphp/pest": "^2.0",
+ "pestphp/pest": "^2.33",
"mockery/mockery": "^1.5.1",
- "worksome/coding-style": "^2.5"
+ "worksome/coding-style": "^2.8"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml b/phpunit.xml
index e57bdd1..f9575ed 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -9,9 +9,9 @@
./tests
-
+
+
diff --git a/src/Dumper.php b/src/Dumper.php
index 9148e49..0383abe 100644
--- a/src/Dumper.php
+++ b/src/Dumper.php
@@ -40,7 +40,7 @@ public function dumpNewLine(string $message = ''): void
}
/**
- * Creates a instance of a progress bar in the specified console output interface.
+ * Creates an instance of a progress bar in the specified console output interface.
*/
public function createProgressBar(int $max = 1): ProgressBar
{
@@ -254,7 +254,7 @@ protected function getColumnsForTable(
}
/**
- * @param array(string=>mixed) $cols
+ * @param array $cols
*/
protected function insertValuesStatement($table, $cols): string
{