for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Nord\Lumen\Elasticsearch\Console;
class CreateCommand extends AbstractCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'elastic:index:create {config : Configuration file}';
* The console command description.
protected $description = 'Creates an Elasticsearch index from a configuration file.';
* @inheritdoc
public function handle()
$config = (string)$this->argument('config');
$filePath = realpath($config);
if (!file_exists($filePath)) {
$this->error(sprintf("Configuration file '%s' does not exist.", $config));
return 1;
}
$params = require($filePath);
$this->info('Creating index ...');
$this->elasticsearchService->indices()->create($params);
$this->info(sprintf("Index '%s' created.", $params['index']));
return 0;