Saya mungkin nubie dalam pemograman, setelah sekian lama saya ngoding (yah 2 taunan lah) ketika mencoba data2 di database saya selau melakukan input data sample dengan manual, ini sangat merepotkan sekali bila saya ingin data banyak dan di modifikasi. dan saya pun melihat lihat projek di github, saya menemukan Faker, tapi waktu itu saya tidak terlalu ngeh apa itu package faker. setelah saya mencoba lagi framework laravel saya menemukan fitur seed. dan barulah saya ngeh memakai faker....hehehe
langung aja gan cek di tempat asal .. faker
// require the Faker autoloader
require_once '/path/to/Faker/src/autoload.php';
// alternatively, use another PSR-0 compliant autoloader (like the Symfony2 ClassLoader for instance)
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
// generate data by accessing properties
echo $faker->name;
// 'Lucy Cechtelar';
echo $faker->address;
// "426 Jordy Lodge
// Cartwrightshire, SC 88120-6700"
echo $faker->text;
// Dolores sit sint laboriosam dolorem culpa et autem. Beatae nam sunt fugit
// et sit et mollitia sed.
// Fuga deserunt tempora facere magni omnis. Omnis quia temporibus laudantium
// sit minima sint.
dan pake for untuk memasukan data banyak
<?php
for ($i=0; $i < 10; $i++) {
echo $faker->name, "\n";
}
Terimkasih
langung aja gan cek di tempat asal .. faker
// require the Faker autoloader
require_once '/path/to/Faker/src/autoload.php';
// alternatively, use another PSR-0 compliant autoloader (like the Symfony2 ClassLoader for instance)
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
// generate data by accessing properties
echo $faker->name;
// 'Lucy Cechtelar';
echo $faker->address;
// "426 Jordy Lodge
// Cartwrightshire, SC 88120-6700"
echo $faker->text;
// Dolores sit sint laboriosam dolorem culpa et autem. Beatae nam sunt fugit
// et sit et mollitia sed.
// Fuga deserunt tempora facere magni omnis. Omnis quia temporibus laudantium
// sit minima sint.
dan pake for untuk memasukan data banyak
<?php
for ($i=0; $i < 10; $i++) {
echo $faker->name, "\n";
}
Terimkasih
0 komentar:
Posting Komentar
Thanks.