Weave Code
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
Multi Search Bundle

Multi Search Bundle Laravel Package

petkopara/multi-search-bundle

Symfony bundle that adds a Multi Search service and form type for Doctrine. Build a QueryBuilder to search across all or selected entity columns using a single term, with optional wildcard matching, and reuse it in your controllers or forms.

View on GitHub
Deep Wiki
Context7

petkopara/multi-search-bundle adds a simple multi-column search for Doctrine entities in Symfony. Provide a search term and get back a Doctrine\ORM\QueryBuilder enriched with OR-based criteria across entity fields.

Use it either as a reusable service to apply search to any existing query builder, or as a convenient form field type for quick integration into your forms.

  • Searches across all entity columns by default
  • Optionally restricts search to specific fields
  • Returns a ready-to-use QueryBuilder for further chaining
  • Includes a MultiSearchType form type for easy UI integration
  • Supports different matching modes (e.g. wildcard)
Frequently asked questions about Multi Search Bundle
Can I use petkopara/multi-search-bundle directly in Laravel without Symfony?
No, this bundle is Symfony-specific and requires Doctrine ORM and Symfony’s DependencyInjection. You’d need to create a Laravel service wrapper to replicate its logic using Eloquent’s QueryBuilder. The core search logic (multi-column queries) is adaptable, but Symfony dependencies like FormBuilder won’t work natively.
What Laravel alternatives exist for multi-column search?
For Laravel, consider spatie/laravel-searchable (Eloquent-based), scout-apm/scout (search-as-a-service), or custom Eloquent macros. These avoid Symfony dependencies and integrate better with Laravel’s ecosystem. For advanced Doctrine features, beberlei/doctrineextensions might help.
How do I adapt this bundle’s search logic to Laravel/Eloquent?
Create a service class wrapping the bundle’s `searchEntity()` logic. Translate Doctrine’s QueryBuilder methods to Eloquent’s (e.g., `andWhere()` → `where()`). Use Laravel’s IoC container to bind the service manually. Example: `public function search(Builder $query, string $model, string $term, array $fields = []) { ... }`
Will this bundle work with Laravel 10 and PHP 8.2?
Unlikely. The last release is from 2016 and may break with PHP 8.0+ features (e.g., named arguments, union types). You’d need to fork it, update dependencies (Doctrine 3.x, Symfony 6+), and test thoroughly. Consider a custom implementation instead.
Does this bundle support wildcard searches like `LIKE '%term%'`?
Yes, it supports wildcard matching (e.g., `'wildcard'` mode). However, wildcard searches are slow on large datasets. For performance, use database full-text indexes (PostgreSQL/MySQL) or offload to Elasticsearch/Algolia.
How do I integrate the MultiSearchType form field into Laravel?
Laravel lacks Symfony’s FormBuilder, so you’d need to replicate the form logic using Laravel Collective, Filament, or a custom FormRequest. The underlying search service can still be used in controllers, but the form type won’t work directly.
Is this bundle secure against SQL injection?
Yes, if used with Doctrine’s QueryBuilder or Laravel’s Eloquent (both sanitize inputs). However, raw SQL or improperly built queries could introduce risks. Always validate search terms and prefer parameterized queries.
How do I restrict searches to specific fields instead of all columns?
Pass an array of field names to the search method. Example: `$qb = $this->get('petkopara_multi_search.builder')->searchEntity($qb, 'AppBundle:Post', $search, ['title', 'content']);` In Laravel, replicate this by filtering fields in your custom service.
What’s the performance impact of wildcard searches on large tables?
Wildcard searches (`LIKE '%term%'`) force full table scans, slowing queries on datasets >10K rows. Mitigate this with database full-text indexes, partial wildcards (`'term%'`), or dedicated search engines like Elasticsearch.
Can I use this bundle for non-Doctrine Eloquent models?
No, the bundle is tightly coupled to Doctrine ORM. For Eloquent, you’d need to rewrite the logic using Laravel’s QueryBuilder. The core concept (multi-column search) is transferable, but Symfony-specific features (e.g., form types) won’t work.
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware