bangpound/elasticsearch-bundle
AppKernel, config.yml) is fundamentally different from Laravel’s service container (ServiceProvider, config.php).AppKernel.php, config.yml) would need a rewrite or wrapper to fit Laravel’s ServiceProvider and config.php paradigms.elasticsearch/elasticsearch) is version-agnostic, but the bundle’s configuration layer (e.g., named clients, logging) would need translation to Laravel’s config/elasticsearch.php.ContainerInterface differs from Laravel’s Illuminate\Container\Container, requiring proxy classes or adapters to bridge the gap.rubix/elasticsearch) be considered instead?elasticsearch/elasticsearch been used directly in Laravel before? If so, what were the pain points?spatie/laravel-elasticsearch-driver) preferable?elasticsearch/elasticsearch library is Laravel-compatible, but the bundle’s Symfony2 glue code is not.caxy_elasticsearch_client service would need to be re-registered in Laravel’s container, likely via a ServiceProvider.config.yml structure must be migrated to Laravel’s config/elasticsearch.php, with support for:
Caxy\Bundle\ElasticsearchBundle.elasticsearch/elasticsearch directly via Composer.namespace App\Providers;
use Elasticsearch\ClientBuilder;
use Illuminate\Support\ServiceProvider;
class ElasticsearchServiceProvider extends ServiceProvider
{
public function register()
{
$config = $this->app['config']['elasticsearch'];
$this->app->singleton('elasticsearch', function () use ($config) {
$builder = ClientBuilder::create();
foreach ($config['clients'] as $name => $clientConfig) {
$builder->setHosts($clientConfig['hosts']);
if (isset($clientConfig['log_path'])) {
$builder->setLogger(...);
}
}
return $builder->build();
});
}
}
// config/elasticsearch.php
return [
'clients' => [
'default' => [
'hosts' => ['localhost:9200'],
],
'named' => [
'hosts' => ['remote-es:9200'],
'log_path' => storage_path('logs/elasticsearch.log'),
],
],
];
Elasticsearch facade for cleaner usage:
use Illuminate\Support\Facades\Facade;
class Elasticsearch extends Facade {
protected static function getFacadeAccessor() { return 'elasticsearch'; }
}
$results = Elasticsearch::search(['index' => 'products', 'body' => [...]]);
spatie/laravel-elasticsearch-driver).ServiceProvider wrapper.| Step | Task | Dependencies |
|---|---|---|
| 1 | Remove caxy/elasticsearch-bundle |
Composer, Laravel |
| 2 | Install elasticsearch/elasticsearch |
Step 1 |
| 3 | Create ElasticsearchServiceProvider |
Step 2 |
| 4 | Migrate config.yml → config/elasticsearch.php |
Step 3 |
| 5 | Build facade/helpers | Step 4 |
| 6 | Update controllers/services to use facade | Step 5 |
| 7 | Deprecate old Symfony2 routes/services | Step 6 |
spatie/laravel-elasticsearch-driver).elasticsearch/elasticsearch client usage is optimized for Laravel.| Risk | Mitigation |
|---|---|
| Connection Failures | Implement retry logic (e.g., Laravel’s retry helper). |
| Configuration Errors | Validate config/elasticsearch.php on boot. |
| Deprecated Symfony2 Code | Use Laravel’s deprecated() helper for old service calls. |
| Package Abandonment | Prefer spatie/laravel-elasticsearch-driver or rubix/elasticsearch if possible. |
ServiceProvider and config structure.ServiceProvider and bind() methods.How can I help you explore Laravel packages today?