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

Search Widget Laravel Package

victoire/search-widget

Victoire Search Widget adds a ready-to-use, configurable search UI to Laravel apps. Drop in a Blade component, connect it to your search backend, and customize styling and behavior to match your site—ideal for adding fast, flexible search without building the front end from scratch.

View on GitHub
Deep Wiki
Context7

Getting Started

The widget is a Victoire CMS extension, so the first step is confirming your Victoire version — this bundle's last release (April 2019) targets Symfony 2.8/3.x and the Victoire widget API of that era.

  1. Install via Composer:
    composer require victoire/search-widget
    
  2. Register the bundle in app/AppKernel.php (Symfony 3 style — there is no Flex recipe):
    new Victoire\Widget\SearchBundle\VictoireWidgetSearchBundle(),
    
  3. Widget registration is self-contained in Resources/config/config.yml, so no manual service wiring is needed. Clear the cache:
    php bin/console cache:clear
    
  4. In the Victoire back office, open a page in edit mode, click Add widget, and the "Search" widget should appear in the picker. Configure its label/placeholder, save, and publish.

First use case: drop the search widget into a header slot in a layout so every published page renders a search form. The form posts to a route you define; the widget itself is the input, not the results page.

Where to look first:

  • Form/WidgetSearchType.php — the editable fields exposed to editors.
  • Entity/WidgetSearch.php — persisted widget settings.
  • Resources/views/show.html.twig — the front-end markup.
  • Resources/config/config.yml — widget name, category, and business-entity scope.

Implementation Patterns

Render the form on a Victoire page. Place the widget on a page or layout; Victoire's slot system handles placement. The widget's show.html.twig renders form_start/form_widget — override it in app/Resources/VictoireWidgetSearchBundle/views/show.html.twig to match your design system without touching the vendor tree.

Wire the results route. The widget only renders the input form. Define a controller action and route (e.g., /search) that reads the query param and renders results. Keep the search execution in your own service so the widget stays presentation-only:

public function searchAction(Request $request, SearchService $search)
{
    $q = trim($request->query->get('q', ''));
    $results = $q ? $search->find($q) : [];
    return $this->render('search/results.html.twig', ['q' => $q, 'results' => $results]);
}

Add editor-configurable fields. Subclass WidgetSearchType and the WidgetSearch entity, add your property (e.g., resultsRoute, resultsLimit), then register your subclass as the widget's form type in the bundle config. This is the sanctioned extension point — do not edit vendor files.

Scope to a business entity. Victoire business entities (Article, Page, custom) are filterable via Victoire's repository helpers. Build a SearchService that runs a query builder over your business entity and respect the widget's stored scope so editors can restrict results per placement.

Integrate with a search backend. For anything beyond a LIKE query, swap your SearchService for an adapter over Elasticsearch / Meilisearch / database full-text. The widget config stays the same; only the service behind the route changes.

i18n. Override the bundle's translation files under app/Resources/translations/ (domain is typically victoire_widget_search). Keep translations per-locale consistent with Victoire's page locale.

Gotchas and Tips

  • It is effectively unmaintained (last release 2019, 5 stars, 0 dependents). Expect incompatibilities with Symfony 4+/5+ (no AppKernel, bundle class moved, autowiring changes). For new projects, plan to fork or reimplement the widget; treat this as a starting point only.
  • Widget entities are Doctrine entities. After adding fields, run doctrine:schema:update (or a migration) — Victoire widgets persist their configuration per placement, so schema drift breaks the back office silently.
  • The widget registers itself; do not duplicate registration. Adding a victoire_core.widgets entry that mirrors the bundle's own config causes duplicate widgets in the picker. Check config.yml before adding anything.
  • Cache clears are mandatory after config or form-type changes. Victoire's HTTP cache also caches rendered pages — publish/clear the page cache in the back office, or the new template/field won't show on the front end.
  • Front-end form defaults. The shipped template may omit CSRF tokens or an explicit method. Verify form_start emits action and method="get" matching your results route, or the form silently posts to the current page.
  • Template override path. Bundle-name resolution in overrides is namespace-prefix sensitive — use app/Resources/VictoireWidgetSearchBundle/views/show.html.twig exactly; a mismatched folder silently falls back to the vendor template.
  • Keep search out of the widget. Editors will expect results to work, but the widget has no built-in result rendering. Document that the results page is application code, or you will field bug reports about "search does nothing."
  • Logging/debugging. If the widget does not appear in the picker, check cache:clear first, then debug:container | grep victoire, then the Victoire widget config — the ordering of those checks saves the most time.
  • Extension point summary: subclass WidgetSearch + WidgetSearchType for fields, override show.html.twig for markup, back the results route with your own service. Those three touchpoints handle almost every real requirement without forking the vendor code.
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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core