PHPackages                             jpcaparas/laravel-faker-openai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jpcaparas/laravel-faker-openai

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jpcaparas/laravel-faker-openai
==============================

An opinionated Laravel package that modifies the service container Faker behaviour to allow prompts to be generated with OpenAI

0.1.0(1y ago)451.4k↑16.7%5[2 issues](https://github.com/jpcaparas/laravel-faker-openai/issues)MITPHPPHP ^8.2

Since Jan 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jpcaparas/laravel-faker-openai)[ Packagist](https://packagist.org/packages/jpcaparas/laravel-faker-openai)[ RSS](/packages/jpcaparas-laravel-faker-openai/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Laravel Faker OpenAI Provider
=============================

[](#laravel-faker-openai-provider)

[![Tests](https://github.com/jpcaparas/laravel-faker-openai/actions/workflows/test.yml/badge.svg)](https://github.com/jpcaparas/laravel-faker-openai/actions/workflows/test.yml/badge.svg)

 [![Usage](./image/usage.gif)](./image/usage.gif)

A Laravel package that extends FakerPHP by adding an AI-powered data generator using OpenAI. This allows you to generate more realistic and context-aware fake data in your Laravel applications.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require jpcaparas/laravel-faker-openai
```

The package will automatically register its service provider if you're using Laravel's package auto-discovery.

Configuration
-------------

[](#configuration)

1. Next, execute the install command:

```
php artisan openai:install
```

This will create a `config/openai.php` configuration file in your project, which you can modify to your needs using environment variables.

2. Make sure you have your OpenAI API key set in your `.env` file:

```
OPENAI_API_KEY=your-api-key-here
```

3. The package uses `gpt-3.5-turbo` model by default.

Usage
-----

[](#usage)

The package adds a new `promptAI()` method to the Faker generator. You can use it in several ways:

### Basic Usage

[](#basic-usage)

```
$faker = app(\Faker\Generator::class);

// Generate a fake name using AI
$name = $faker->promptAI('name');

// Generate a movie review
$review = $faker->promptAI('movieReview');

// Generate a movie description
$description = $faker->promptAI('movieDescription');
```

... you can also use the built-in `fake()` helper:

```
$name = fake('name');
```

### With Fallback Values

[](#with-fallback-values)

You can provide fallback values that will be used if the AI request fails:

```
// String fallback
$name = $faker->promptAI('name', 'John Doe');

// Closure fallback
$name = $faker->promptAI('name', fn() => 'John Doe');
```

### Error Handling

[](#error-handling)

By default, errors are logged and the fallback value is returned. You can make it throw exceptions instead:

```
try {
    $name = $faker->promptAI('name', null, true); // Set throwOnError to true
} catch (\Exception $e) {
    // Handle the error
}
```

How It Works
------------

[](#how-it-works)

The package works by:

1. Intercepting FakerPHP method calls through a prompt
2. Sending them to OpenAI's GPT model
3. Returning AI-generated responses that match FakerPHP's expected output format

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

533d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2406808?v=4)[JP Caparas](/maintainers/jpcaparas)[@jpcaparas](https://github.com/jpcaparas)

---

Top Contributors

[![jpcaparas](https://avatars.githubusercontent.com/u/2406808?v=4)](https://github.com/jpcaparas "jpcaparas (6 commits)")[![ylynfatt](https://avatars.githubusercontent.com/u/19831?v=4)](https://github.com/ylynfatt "ylynfatt (1 commits)")

---

Tags

fakerlaravelopenaitesting

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jpcaparas-laravel-faker-openai/health.svg)

```
[![Health](https://phpackages.com/badges/jpcaparas-laravel-faker-openai/health.svg)](https://phpackages.com/packages/jpcaparas-laravel-faker-openai)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.8k](/packages/orchestra-testbench)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.4k](/packages/typicms-base)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49517.1k](/packages/blackfire-player)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M519](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
