asika/faker-zhtw

This package is abandoned and no longer maintained. The author suggests using the fzaninotto/faker package instead.

A repository to hold PHP Faker zh_TW provider until Faker release new version.

1.0.0 2015-02-21 17:09 UTC

This package is auto-updated.

Last update: 2019-02-21 09:17:24 UTC


README

Currently Faker has a zh_TW provider but still not release in newest stable version.

If we want to use zh_TW provider but do not hope to load unstable packages, we can use this repository instead, until Faker release a new version.

The source was created by Tz-Huan Huang

2015-02-22

How To Use

$faker = \Faker\Factory::create('zh_TW');

$faker->addProvider(new \Faker\Provider\zh_TW\Address($faker));
$faker->addProvider(new \Faker\Provider\zh_TW\Company($faker));
$faker->addProvider(new \Faker\Provider\zh_TW\Person($faker));
$faker->addProvider(new \Faker\Provider\zh_TW\PhoneNumber($faker));
$faker->addProvider(new \Faker\Provider\zh_TW\Text($faker));

foreach (range(1, 50) as $i)
{
	$data['name'] = $faker->name;
	$data['username'] = $faker->username;
	$data['password'] = password_hash('pass');
	$data['email'] = $faker->email;
	$data['nick'] = $faker->firstName;
	$data['mobile'] = $faker->phoneNumber;
	$data['phone'] = $faker->phoneNumber;
	$data['address'] = $faker->address;
	$data['organization'] = $faker->company;
	$data['title'] = $faker->title;
	$data['state'] = $faker->randomElement([1,1,1,0]);
	$data['registered'] = $faker->dateTime->format('Y-m-d H:s:i');
	$data['last_login'] = $faker->dateTime->format('Y-m-d H:s:i');

	$this->db->getWriter()->insertOne('users', $data);
}

Installation

{
	"require": {
		"asika/faker-zhtw": "*@stable"
	}
}