Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Fakerphp Lorem Toneflix Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. 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.
  2. 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.
  3. The hosted endpoint — hit 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.

Implementation Patterns

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.

Gotchas and Tips

  • Every call is a network round trip. Faker's built-in 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.
  • Your test suite inherits that dependency. Without 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().
  • Seeding is not deterministic. $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.
  • Return type is ambiguous until verified. Faker's core image provider returns a URL string; a custom provider may return bytes, a URL, or an array. Check before assigning to a column and before rendering in Blade — a binary blob stuffed into an <img src> will silently produce a broken layout.
  • Mixed content. If the endpoint returns http:// URLs, they will be blocked on any HTTPS page. Normalize with str_replace('http://', 'https://', $url) after verifying the host serves TLS.
  • No SLA, no dependents, 0 stars. This is a one-person package pointed at a personally hosted domain. It can rate-limit, change its URL scheme, or disappear. Pin the version in composer.json, keep it in require-dev, and never call it from production code paths.
  • Laravel binding subtlety. 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.
  • Class name and namespace guesses. Verify the exact FQCN from src/ and any auto-discovery entry; a wrong namespace in addProvider() produces a confusing "call to undefined method" far from the real cause.
  • Debugging: wrap calls in Http::globalRequestMiddleware() or log the resolved URL before assigning it. Most failures are DNS, 429s, or TLS — not provider logic.
  • Extension points: subclass the shipped provider to add caching or fallbacks, or decorate it behind your own helper. Don't patch vendor/; there is no active upstream to merge fixes.
  • Licensing split. The package is MIT, but the image service has its own terms. Attribute or replace it before anything user-facing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource