PHP Classes

PHP Random User Generator: Generate random data for users from randomuser.me

Recommend this page to a friend!
  Info   View files Example   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 80 All time: 9,806 This week: 193Up
Version License PHP version Categories
random-user-php-sdk 1.0.0The PHP License5User Management, Web services
Description Author

This package can generate random data for users from randomuser.me .

It can send HTTP requests to the randomuser.me to retrieve data for user records with based on given parameter values.

The package takes values for certain parameters to be included or excluded in the generated user data like the user nationality, gender, name, location, email, login, registered, date of birth, phone number cell phone number, id and picture.

Picture of Roman Kozin
  Performance   Level  
Name: Roman Kozin <contact>
Classes: 5 packages by
Country: Ukraine Ukraine
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Details

Random User PHP SDK

This SDK allows You to generate from 1 to 2048 users at one time

API

KielD01\RandomUser::__construct($version = null) Sets the latest version, if $version is null or throws an Exception.

KielD01\RandomUser::asJson() Sets the header of Content-Type to application/json.

KielD01\RandomUser::setVersion($version = null) Sets the $this->version to $version. Throws an Exception.

KielD01\RandomUser::setOutputFormat($format = null) Sets the output format between 'json', 'xml', 'pretty', 'yaml', 'csv'

KielD01\RandomUser::setResultsCount($results = null) Sets results count. Available range is from 1 to 2048.

KielD01\RandomUser::setPage($page = 1) Sets results page

KielD01\RandomUser::setSeed($seed = null) Sets seed

KielD01\RandomUser::setNoInfo($noInfo = false) Disable or Enable info object.

KielD01\RandomUser::setNationalityOnly($nationality = null, $value = false) Set nationality value or values to $value

KielD01\RandomUser::setIncludedOrExcludedFields($type = 'inc', $fields = null, $value = true) Sets included or excluded fields

KielD01\RandomUser::getVersion() Returns version

KielD01\RandomUser::getNationalities() Returns nationalities list due to version

KielD01\RandomUser::getQuery() Returns request query to be sent

KielD01\RandomUser::getResults() Returns KielD01\RandomUser\Helpers\Colelction, which contains items array of an KielD01\RandomUser\Helpers\Entity

KielD01\RandomUser::fetch($debug = false) Fetch the results from the API and transform it into KielD01\RandomUser\Helpers\Collection

Example

<?php

use KielD01\RandomUser\RandomUser;

try {
    $randomUser = new RandomUser('1.1');

    $results = $randomUser
        ->setNationalityOnly('us', true)
        ->setResultsCount(50)
        ->fetch()
        ->getResults();

    // ToDo : Process with $results
} catch (Exception $e) {
    echo "<pre>{$e->getMessage()}</pre>";
}
  Files folder image Files  
File Role Description
Files folder imageexample (1 file)
Files folder imagesrc (2 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageHelpers (3 files)
Files folder imageModels (5 files)
  Plain text file Info.php Class Class source
  Plain text file RandomUser.php Class Class source

  Files folder image Files  /  src  /  Helpers  
File Role Description
  Plain text file Collection.php Class Class source
  Plain text file Entity.php Class Class source
  Accessible without login Plain text file Functions.php Aux. Auxiliary script

  Files folder image Files  /  src  /  Models  
File Role Description
  Plain text file ID.php Class Class source
  Plain text file Location.php Class Class source
  Plain text file Login.php Class Class source
  Plain text file Name.php Class Class source
  Plain text file Picture.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:80
This week:0
All time:9,806
This week:193Up
For more information send a message to info at phpclasses dot org.