PHP code example of cspivack / faker-baseball

1. Go to this page and download the library: Download cspivack/faker-baseball library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cspivack / faker-baseball example snippets




$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\FightingBaseballProvider($faker));

/* General data */
$faker->playerName();          // A name using random first and last names
$faker->playerPosition();      // One of the positions in the game
$faker->playerTeam();          // One of the teams in the game

/* Data for a specific player */
$faker->player()->name();      // A player's full name
$faker->player()->firstName(); // A player's first name
$faker->player()->lastName();  // A player's first name
$faker->player()->team();      // A player's team
$faker->player()->position();  // A player's position
$faker->player()->benched();   // Whether the player is coming off the bench or not (boolean)

public function register()
{
    $this->app->singleton(Generator::class, function () {
        $faker = Factory::create();
        $faker->addProvider(new \Faker\Provider\FightingBaseballProvider($faker));
        return $faker;
    });
}