plixus/twig-component-preview-bundle
A Symfony bundle that adds a preview environment for Twig components, letting developers render and inspect individual components in isolation during development. Useful for building and reviewing UI pieces outside full page templates.
This package generates Blade component names from PHP classes. The v1.0.1 release fixes the namespace configuration problem that previously surfaced as Could not generate a component name for class... by introducing a name_prefix config parameter — so the first thing to do on any existing install is re-publish (or diff) the config file, because the new key will not exist in a config you published under an earlier version.
composer require <vendor>/<package> (constraint ^1.0.1 — anything below it will keep hitting the naming error under namespaced classes).php artisan vendor:publish --tag=<package>-config (use --force only after diffing against your current file; see Gotchas).name_prefix to something stable and project-specific, e.g. 'name_prefix' => 'app'. This value is folded into the generated component name and is what stops two classes with the same short name in different namespaces from colliding.php artisan config:clear (or optimize:clear), then run the generator/registration command for one class and confirm the resulting Blade file renders with <x-... />.Look first at: the published config file (that's where name_prefix lives), then the package's service provider to see whether components are registered at boot from config or generated ahead of time by an artisan command. Those two facts determine almost everything about how you'll integrate it.
First real use case: take one existing namespaced class (a view model, a DTO, a domain-specific presenter) and expose it as a component. Getting a single App\ViewModels\InvoiceSummary → <x-app-invoice-summary /> working end-to-end proves the prefix, the namespace mapping, and the view resolution path all at once. Do this before touching a second class.
Pin the prefix per application, not per module. name_prefix is global config, so treat it as an application-level constant set once in .env (NAME_PREFIX=app) and read via config(). Changing it later renames every generated component, which is a silent breaking change for every Blade file that references them.
Namespace → component name mapping. The package derives a name from the class's namespace relative to whatever root namespace you configure. In practice: configure the root namespace(s) that contain your component-eligible classes, and keep that list narrow. Pointing it at App\ wholesale means every new class becomes a candidate component, including things you never intended to render.
Domain/module isolation. If you're on a modular codebase, the natural pattern is one root namespace per module plus a distinct prefix, e.g. billing and reports, yielding <x-billing-invoice-total /> and <x-reports-invoice-total />. This is exactly the collision the name_prefix fix addresses — two InvoiceTotal classes in different namespaces previously produced an unresolvable name. If you're upgrading, audit for classes that were silently skipped or collided before v1.0.1; they may now start generating names, which means new components appearing in your build.
Generated vs. runtime. If the package writes component classes/files, run generation as part of your build or a dedicated artisan step rather than on every request, and commit the output. If it registers dynamically at boot, watch boot cost on large directories and verify it plays nicely with php artisan optimize / config caching.
Testing. Add a small smoke test that asserts each configured namespace produces a non-empty component name — this is the assertion that would have caught the v1.0.1 bug. A unit test iterating registered classes and calling the name generator is cheap insurance against the next namespace change.
Blade integration. Prefer the <x-prefix-name /> syntax over @component directives so the generated name mapping stays visible at the call site. Keep props/attributes documented next to the class rather than only in the Blade file.
composer update alone will not fix the Could not generate a component name for class... error — without name_prefix present in your published config, behaviour depends on whether the package ships a merged default. Diff your config against the vendor copy immediately after updating.vendor:publish --force will clobber your tuned namespace list. Publish to a temp tag or diff manually; only the new name_prefix key should be added.php artisan config:clear. If you're on a deploy pipeline that runs config:cache, the stale value will survive a code deploy.App\Billing\Invoices\Summary typically becomes billing-invoices-summary (or dotted equivalents). Long chains plus a prefix can exceed whatever length cap the generator enforces — keep nesting shallow and names short.name_prefix affect the generated component tag; pick something kebab-safe so <x-...> doesn't require quoting or awkward escaping.php artisan tinker and inspect the output before hunting through Blade compilation. It's nearly always the namespace root or the prefix, not the renderer.name_prefix gives you, the cleanest route is usually a thin wrapper service provider in each module that calls the package's generator with an overridden config, rather than fighting the global value. Confirm against the package source whether the generator reads config statically or accepts injection — static reads will force you into config-array manipulation.name_prefix is brand new in v1.0.1 and the pre-fix naming behaviour is effectively deprecated by it. Assume the implicit "derive name from namespace only" path will be removed in the next minor; don't build against it.How can I help you explore Laravel packages today?