jeroen-g/explorer
Laravel-friendly, fluent API for exploring and filtering directories and files. Chain common queries (name, extension, size, modified time), include/exclude patterns, sort and paginate results, and iterate over matches with clean, expressive code.
Strengths:
search(), paginate(), cursor()), reducing boilerplate and maintaining consistency with Laravel’s ecosystem.Fit for Use Cases:
LIKE queries with Elasticsearch’s inverted index for sub-millisecond response times.terms, date_histogram) for dashboards or reporting.Limitations:
toSearchableArray()). Eventual consistency must be managed (e.g., via Laravel Scout’s searchable() events).Prerequisites:
config/scout.php driver set to elastic).php-curl, php-json (required by Elasticsearch PHP client).Migration Path:
Post) to validate performance and query accuracy.scout:import to backfill existing data.searchable() events to sync changes.Post::search('term')->get()).Compatibility:
Data Consistency:
searchable() events fail or data isn’t reindexed.searchable events asynchronously.scout:flush) to verify index counts match database records.toSearchableArray() hooks for custom sync logic.Performance:
match_all queries, unoptimized analyzers).ElasticEngine::debug() and Kibana’s Dev Tools.->paginate(10)) or cursor-based scrolling.keyword mappings for exact matches (e.g., IDs, categories) and text for full-text.Operational Complexity:
logger config to debug connection issues.Vendor Lock-in:
nested types unless necessary).LIKE queries)?Laravel Ecosystem:
database, algolia) with Elasticsearch. Leverage existing Scout features like:
search(), paginate(), cursor() for consistent API.toSearchableArray() for custom data transformation.searchable() events for syncing changes.JeroenG\Explorer\ExplorerServiceProvider), which integrates with Laravel’s IoC container.scout:import, elastic:update, scout:delete-index).Elasticsearch Stack:
elastic/elasticsearch-php client, which supports all Elasticsearch APIs.bool, match, aggregations) via Scout methods or raw queries.Testing:
FakeResponse (see testing.md) to avoid dependency on a live cluster.Preparation:
php artisan vendor:publish --tag=explorer.config.driver => 'elastic' in config/scout.php.config/explorer.php (e.g., posts_index).composer require jeroen-g/explorer
composer require elastic/elasticsearch
Pilot Phase:
Post, Product).title => 'text', published_at => 'date').php artisan scout:import "App\Models\Post"
$results = Post::search('laravel')->paginate(10);
Incremental Rollout:
searchable() events.scout:import via Laravel’s scheduler.elastic:update to manage aliases for zero-downtime updates.Deprecation:
How can I help you explore Laravel packages today?