Skip to content

Laravel AI Faker is a package that enhances Laravel's Faker by using AI to generate realistic, context-aware fake data. It automatically scans your models, analyzes attributes and relationships, and produces meaningful data for development and testing environments. Perfect for creating lifelike test scenarios with minimal effort.

Notifications You must be signed in to change notification settings

kimani-dev/laravel-ai-faker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel AI Faker

Laravel AI Faker is a package that enhances Laravel's default Faker functionality by leveraging AI to generate realistic, context-aware fake data. This package scans your models, analyzes their attributes and relationships, and produces meaningful data for development and testing environments.


Features

  • AI-Powered Data Generation: Generates more realistic fake data using AI (e.g., OpenAI).
  • Model Analysis: Automatically detects model attributes and relationships to provide context-aware data.
  • Seamless Integration: Works seamlessly with Laravel factories and database seeding.
  • Configurable: Customize AI prompts and settings for tailored results.

Installation

Require the package via Composer:

composer require kimani/laravel-ai-faker

If you're using AI services like OpenAI, publish the configuration file:

php artisan vendor:publish --provider="Kimani\AIFaker\AIFakerServiceProvider"

Then, add your API key to the configuration file or .env file:

AIFAKER_API_KEY=your-api-key-here

Usage

Generating Fake Data

Use the AIFaker service in your factories:

use Kimani\AIFaker\Services\AIFaker;

$aiFaker = app(AIFaker::class);

return $aiFaker->generateFakeData(new \App\Models\YourModel());

Example Factory Integration

In your Laravel factory:

use Kimani\AIFaker\Services\AIFaker;

/** @var \Kimani\AIFaker\Services\AIFaker $aiFaker */
$aiFaker = app(AIFaker::class);

\App\Models\YourModel::factory()->define(function () use ($aiFaker) {
    return $aiFaker->generateFakeData(new \App\Models\YourModel());
});

Configuration

The configuration file (config/aifaker.php) allows you to customize:

  • AI provider and API key
  • AI model and parameters
  • Default behavior for data generation

Testing

Run the tests with:

vendor/bin/phpunit

Contributing

Contributions are welcome! Please submit a pull request or open an issue to report bugs or suggest features.


License

This package is open-source and licensed under the MIT License.


Credits

Developed by David Kimani.

About

Laravel AI Faker is a package that enhances Laravel's Faker by using AI to generate realistic, context-aware fake data. It automatically scans your models, analyzes attributes and relationships, and produces meaningful data for development and testing environments. Perfect for creating lifelike test scenarios with minimal effort.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages