Last active
May 25, 2019 18:46
-
-
Save barryhughes/7f726dfa6f05aa7bce684ba036d0620e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Simple script to generate a bunch of randomish names, email addresses | |
| * etc. Outputs CSV which can be piped into a file, etc. | |
| * | |
| * Adapt and modify as needed...remember there are more powerful tools out | |
| * there for this sort of thing if you have more complicated needs: | |
| * | |
| * @see https://github.com/fzaninotto/Faker | |
| * @see https://github.com/gevans/phaker | |
| */ | |
| $first_names = [ | |
| 'Abbas', | |
| 'Annabelle', | |
| 'Archie', | |
| 'Belinda', | |
| 'Bruce', | |
| 'Davey', | |
| 'Donna', | |
| 'Edna', | |
| 'Edgar', | |
| 'Ethelbert', | |
| 'Fakhir', | |
| 'Fiona', | |
| 'Fred', | |
| 'Gayle', | |
| 'Greg', | |
| 'Heidi', | |
| 'Henry', | |
| 'Ingrid', | |
| 'Innis', | |
| 'Jabbar', | |
| 'Jim', | |
| 'Joanne', | |
| 'Kareem', | |
| 'Karen', | |
| 'Kevin', | |
| 'Len', | |
| 'Lena', | |
| 'Martin', | |
| 'Melinda', | |
| 'Mubarak', | |
| 'Nina', | |
| 'Norbert', | |
| 'Oscar', | |
| 'Othella', | |
| 'Patricia', | |
| 'Paul', | |
| 'Qing', | |
| 'Quentin', | |
| 'Radwan', | |
| 'Rachel', | |
| 'Sadie', | |
| 'Samuel', | |
| 'Tabitha', | |
| 'Timin', | |
| 'Tony', | |
| 'Umberto', | |
| 'Una', | |
| 'Veronica', | |
| 'Victor', | |
| 'William', | |
| 'Wilma', | |
| 'Xanthe', | |
| 'Xavier', | |
| 'Yael', | |
| 'Yasmine', | |
| 'Zandra', | |
| 'Zane', | |
| ]; | |
| $last_names = [ | |
| 'Almasi', | |
| 'Anderson', | |
| 'Brucefield', | |
| 'Coleman', | |
| 'Dickinson', | |
| 'Essa', | |
| 'Franco', | |
| 'Garcia', | |
| 'Hernandez', | |
| 'Inglis', | |
| 'Jordan', | |
| 'Kelly', | |
| 'Khan', | |
| 'Khoury', | |
| 'King', | |
| 'Lín', | |
| 'Maldonado', | |
| 'Nahas', | |
| 'Núnez', | |
| 'Otherly', | |
| 'Phillips', | |
| 'Quigley', | |
| 'Rodríguez', | |
| 'Sandringham', | |
| 'Thompson', | |
| 'Underhill', | |
| 'Veracruz', | |
| 'Wasem', | |
| 'Wilson', | |
| 'Wong', | |
| 'Xanderson', | |
| 'Xiāo', | |
| 'Yule', | |
| 'Zhang', | |
| ]; | |
| $email_providers = [ | |
| 'grabmail.fake.info', | |
| 'instapost.test.email', | |
| 'offline.simulated.net', | |
| 'pretend.user.web', | |
| 'quickimail.interwebs', | |
| 'test.example.com', | |
| ]; | |
| $roles = [ | |
| 'subscriber', | |
| 'contributor', | |
| 'administrator', | |
| ]; | |
| shuffle( $first_names ); | |
| shuffle( $last_names ); | |
| $out = []; | |
| while ( count( $out ) < 50 ) { | |
| if ( ! next( $first_names ) ) { | |
| shuffle( $first_names ); | |
| reset( $first_names ); | |
| } | |
| if ( ! next( $last_names ) ) { | |
| shuffle( $last_names ); | |
| reset( $last_names ); | |
| } | |
| $first_name = current( $first_names ); | |
| $last_name = current( $last_names ); | |
| $possible_name = "$first_name $last_name"; | |
| if ( isset( $out[ $possible_name ] ) ) { | |
| continue; | |
| } | |
| $slug = str_replace( ' ', '-', strtolower( $possible_name ) ); | |
| $email_provider = $email_providers[ array_rand( $email_providers ) ]; | |
| $out[ $possible_name ] = [ | |
| 'username' => "{$slug}_test_user", | |
| 'email' => "{$slug}@{$email_provider}", | |
| 'role' => $roles[ array_rand( $roles ) ], | |
| ]; | |
| } | |
| foreach ( $out as $name => $property ) { | |
| print "{$name},{$property['username']},{$property['email']},{$property['role']}\n"; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample use:
php 50-fake-users-as-csv.php > my-user-list.csv