# $this->faker is an instance of the FakerPHP library (ok)

In Laravel, `$this->faker` is an instance of the [FakerPHP library](https://fakerphp.org/) available within [Model Factories](https://laravel.com/docs/13.x/eloquent-factories) and tests using the `WithFaker` trait. ![Laravel](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2FwnT8ozg2qSnZ0trWN1gY%2FLaravel?alt=media\&token=c97fc1eb-1f5b-45fc-826c-098e804104a3)Laravel +1Below is a categorized list of commonly used methods (formatters) available via `$this->faker`:**1. Personal Information**

* `$this->faker->name()`: Full name
* `$this->faker->firstName()` / `lastName()`: Specific parts of a name
* `$this->faker->title()`: Prefix (e.g., Mr., Mrs., Dr.)
* `$this->faker->phoneNumber()`: Random phone number
* `$this->faker->jobTitle()`: Job title (e.g., Developer) ![Faker docs](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAACVBMVEVGUVji5+uMoa9+AXGPAAAALElEQVQ4jWNgoAtgggMghxEZUFMBgoKJ0l/BqDdpoYCgG+iggA7eJEMBjQEArjYC0yPH5IIAAAAASUVORK5CYII=)Faker docs +3

**2. Text & Content**

* `$this->faker->word()`: A single random word
* `$this->faker->sentence()`: A single sentence
* `$this->faker->paragraph()`: A single paragraph
* `$this->faker->text()`: A larger block of text
* `$this->faker->realText()`: More natural-sounding text (available for different locales) ![Faker docs](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAACVBMVEVGUVji5+uMoa9+AXGPAAAALElEQVQ4jWNgoAtgggMghxEZUFMBgoKJ0l/BqDdpoYCgG+iggA7eJEMBjQEArjYC0yPH5IIAAAAASUVORK5CYII=)Faker docs +4

**3. Address & Location**

* `$this->faker->address()`: Full address
* `$this->faker->streetAddress()`: Street name and number
* `$this->faker->city()` / `state()` / `postcode()`: Specific location parts
* `$this->faker->country()`: Random country name
* `$this->faker->latitude()` / `longitude()`: Geographic coordinates ![Faker docs](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAACVBMVEVGUVji5+uMoa9+AXGPAAAALElEQVQ4jWNgoAtgggMghxEZUFMBgoKJ0l/BqDdpoYCgG+iggA7eJEMBjQEArjYC0yPH5IIAAAAASUVORK5CYII=)Faker docs +2

**4. Internet & Tech**

* `$this->faker->safeEmail()`: An email address guaranteed not to exist
* `$this->faker->userName()`: A random username
* `$this->faker->password()`: A random string for passwords
* `$this->faker->domainName()`: Example: `example.com`
* `$this->faker->url()`: A full random URL
* `$this->faker->ipv4()`: A random IP address ![Laravel](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2F3VimnKAkxpiuX12mniqI%2FLaravel?alt=media\&token=e7924729-0ee3-4f9a-b856-60f3b2504e30)Laravel +2

**5. Dates & Numbers**

* `$this->faker->date()`: Random date (e.g., `2024-03-25`)
* `$this->faker->dateTimeBetween('-1 year', 'now')`: A date object within a range
* `$this->faker->randomNumber()`: A random integer
* `$this->faker->randomFloat()`: A random decimal number
* `$this->faker->boolean()`: `true` or `false`&#x20;

**6. Modifiers**Faker allows you to wrap calls to ensure specific behaviors: ![Packagist](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2FTo05PrNwkQg1M6HvUkot%2FPackagist?alt=media\&token=8def7d28-510d-4ba3-82d3-5a4995b0fdcb)Packagist

* `$this->faker->unique()->email()`: Ensures the generated email is unique for that run.
* `$this->faker->optional()->text()`: Sometimes returns the value, sometimes returns `null`.
* `$this->faker->randomElement(['active', 'pending', 'deleted'])`: Picks one item from a custom array. ![Laracasts](https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2FwAvPpGkOsMXNdt26f2UE%2FLaracasts?alt=media\&token=b8eaab3f-a334-4e22-af51-129141c2dc6b)Laracasts +2

For a complete and searchable list of every available formatter, refer to the [FakerPHP Available Formatters Documentation](https://fakerphp.org/formatters/).&#x20;
