toneflix-code/fakerphp-lorem-toneflix
A FakerPHP provider that adds ToneFlix-flavored lorem ipsum to your PHP projects. Generate themed placeholder words, sentences, and paragraphs for factories, seeders, and test fixtures through a simple, drop-in API.
This is a dev-only Faker provider that adds an alternative image source (pictwo.toneflix.net) — and, given the package name, likely lorem-text methods — on top of fakerphp/faker. Treat it as a seeding/demo-data tool, not a runtime dependency.
composer require --dev toneflix-code/fakerphp-lorem-toneflix
Where to look first:
composer.json — confirm the PHP and fakerphp/faker version constraints, and check extra.laravel.providers for an auto-discovered service provider. With 0 stars and a single release, assume nothing is auto-wired until you verify.src/ — find the provider class (it will extend Faker\Provider\Base) and scan its public methods. That is your real API surface; method names like imageUrl(), image(), or lorem variants are guesses until you read the source.https://pictwo.toneflix.net once in a browser to see whether it returns redirects, image bytes, or a URL string, and whether HTTPS is valid.First use case: seed a demo blog with cover images and body copy.
// database/seeders/DemoSeeder.php
use Faker\Factory;
$faker = Factory::create();
$faker->addProvider(new \Toneflix\Lorem\Provider($faker)); // verify class name
Post::factory()->count(20)->create([
'cover_url' => fn () => $faker->imageUrl(1200, 630),
'body' => fn () => $faker->paragraphs(4, true),
]);
If the package ships a Laravel service provider, this is enough — fake() will already have the provider attached. If not, see the registration pattern below.
Register once, globally (Laravel). Hook the container binding in a service provider's register() so every factory and fake() call gets the provider:
// app/Providers/FakerServiceProvider.php
public function register(): void
{
$this->app->extend(\Faker\Generator::class, function ($faker) {
$faker->addProvider(new \Toneflix\Lorem\Provider($faker));
return $faker;
});
}
Register in register(), not boot() — once the singleton has been resolved, extend() no longer applies to the existing instance.
Standalone seeders. For scripts outside the container (artisan commands, one-off importers), Faker\Factory::create() plus addProvider() is the most predictable path and avoids fighting Laravel's container lifecycle.
Wrap generation in a resolver with a local fallback. This is the single most valuable pattern with a remote-backed provider:
function demo_image(int $w = 800, int $h = 600): string
{
try {
return cache()->remember("faker_img:{$w}x{$h}:" . Str::random(8), now()->addDay(), function () use ($w, $h) {
$faker = \Faker\Factory::create();
$faker->addProvider(new \Toneflix\Lorem\Provider($faker));
return $faker->imageUrl($w, $h);
});
} catch (\Throwable $e) {
report($e);
return "https://picsum.photos/{$w}/{$h}";
}
}
Download once, store locally. If your app renders images from storage/, resolve the URL once, download it, and write the local path to the DB. This converts an N-request seeder into an N-request one-time job and makes reseeding free:
$url = demo_image();
$path = 'covers/' . Str::uuid() . '.jpg';
Storage::disk('public')->put($path, Http::timeout(10)->get($url)->body());
Batch generation in a job. For hundreds of records, do the HTTP work inside a queued job with ->timeout() and ->retry(2, 500). Never loop the provider synchronously over 1,000 rows — you will wait minutes and likely hit rate limits.
Test isolation. In Pest/PHPUnit, blanket-fake the network so CI never depends on toneflix being up:
Http::fake(['pictwo.toneflix.net/*' => Http::response('', 200, ['Content-Type' => 'image/jpeg'])]);
Or better, stub your demo_image() helper and never exercise the provider in unit tests at all.
Integration tip: keep provider calls behind a single application-level helper (demo_image(), demo_text()), so swapping this package out later is a one-file change.
imageUrl() is a pure string builder; this one is not. Seeding 500 rows with remote calls is 500 HTTP requests — seconds-to-minutes of wall time and a hard dependency on a third-party host.Http::fake() or a stubbed helper, php artisan test fails offline, on a plane, and whenever the host is down. Make network faking the default in tests/Pest.php / TestCase::setUp().$faker->seed(1234) controls the generator, not the remote service. Two runs can produce different images. If reproducibility matters, persist generated URLs/paths as fixtures instead.<img src> will silently produce a broken layout.http:// URLs, they will be blocked on any HTTPS page. Normalize with str_replace('http://', 'https://', $url) after verifying the host serves TLS.composer.json, keep it in require-dev, and never call it from production code paths.fake() and Faker\Generator resolution don't always share state with a generator you constructed manually. If methods appear missing inside factories, the provider wasn't attached to that instance — fix it at the container extend() level rather than in individual tests.src/ and any auto-discovery entry; a wrong namespace in addProvider() produces a confusing "call to undefined method" far from the real cause.Http::globalRequestMiddleware() or log the resolved URL before assigning it. Most failures are DNS, 429s, or TLS — not provider logic.vendor/; there is no active upstream to merge fixes.How can I help you explore Laravel packages today?