Data will be manipulated from production (source) to staging (target). This tool will be definitely needed when you dislike to work with real data from your users.
The main job of this package to fake data that GDPR relevant is. Take a look at the following List:
- Name
- Email Address
- Phone number
- Credit cards
- Date of birth
- Place of birth
- Identification number
- Online data
- IP address
- Location data (GPS)
 
- Images
- License plate
- Health data
This list must be considered, when you try to work with real Data, therefore  GDPR relevant data must be transformed.
The Rest will be then 1:1 taken.
composer require ipunkt/data-transformer
Or
Alternative you can add these lines into your composer file then composer install in console command
"require": {
	"ipunkt/data-transformer": "^1.0"
}
I assume that you already have a connection in your database.php. like the following
'mysql' => [
       'driver' => 'mysql',
       'host' => env('DB_HOST', '127.0.0.1'),
       'port' => env('DB_PORT', '3306'),
       'database' => env('DB_DATABASE', 'forge'),
       'username' => env('DB_USERNAME', 'forge'),
       'password' => env('DB_PASSWORD', ''),
       'unix_socket' => env('DB_SOCKET', ''),
       'charset' => 'utf8mb4',
       'collation' => 'utf8mb4_unicode_ci',
       'prefix' => '',
       'prefix_indexes' => true,
       'strict' => true,
       'engine' => null,
   ],
You will be asked about the connection which is for source, when you run later on both of commands.
php artisan transform:dump and php artisan transfrom:data
- run this command: php artisan vendor:publishthen chooseIpunkt\DataTransformer\DataTransformerServiceProvider
- find your Config File in config/data-transformer.php
- edit your Config for instance: nametousernameand/orfakeNametovalueor vice versa
- run php artisan transform:dump {host} {db} {username} {password}your standard config File will bedata-transformer.jsonyou'll find it in the root of your Application. An Examplephp artisan transform:dump 000.000.0.000 transformer root pw
- 000.000.0.000-->- IP addressas- host
- transformer-->- DB_NAME
- root-->- USERNAME
- pw-->- PASSWORDin- data-transformer.jsonyou'll find something like this:
{
 "users": {
   "id": "value",
   "name": "fakeName",
   "email": "fakeEmail",
   "action_on_redeem_json": "value",
   "action_on_expire_json": "value",
   "created_at": "value",
   "updated_at": "value"
 }
}
Here's the all list with data that could be transformed:
- name=>- fakeNamevia faker- $this->faker->name
- email=>- fakeEmailvia faker- $this->faker->safeEmail
- place_of_birth=>- fakePlaceOfBirthvia faker- $this->faker->country
- data_health=>- fakeDataHealthvia faker- $this->faker->randomDigit
- id_number=>- fakeIDvia faker- $this->faker->uuid
- phone_number=>- fakePhoneNumbervia faker- $this->faker->phoneNumber
- credit=>- fakeCreditvia faker- $this->faker->bankAccountNumber
- license_plate=>- fakeLicensePlatevia faker- $this->faker->randomLetter
- image=>- fakeImagevia faker- $this->faker->image
- ip_address=>- fakeIPAddressvia faker- $this->faker->localIpv4
- data_location=>- fakeDataLocationvia faker- $this->faker->latitude
- address=>- fakeAddressvia faker- $this->faker->address
- date_of_birth=>- fakeDateOfBirthvia faker- $this->faker->dateTime()->format('Y-m-d')
Here you can decide whether the Name must be transformed or not, for instances. If you let the Name without any change then it will be faked. If you don't want to transform Name, then you have to replace the fakeName with value. That's it.
The second and last Step:
run the second command php artisan transform: {host} {db} {username} {password} (like transform:dump command)
{--target=mysql}
you have to change the mysql to whatever it is in your database.php
If you want to disable foreign keys that tables has/have, add the following flag foreign-keys-checks
at the end of the second Command:
php artisan transform:dump {source} {target} --foreign-keys-checks=no
Note:
if you changed your config file, then it is required otherwise you don't need to do anything else.
And you're Done!