I have installed the elasticsearch(version 6.4) in my local system. And I have to install this package via composer. And it installed perfectly but at the end, I'm getting following error
`Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover
Elasticsearch\Common\Exceptions\InvalidArgumentException : Could not parse URI at /var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:669
665| {
666| $parts = parse_url($host);
667|
668| if ($parts === false) {
669| throw new InvalidArgumentException("Could not parse URI");
670| }
671|
672| if (isset($parts['port']) !== true) {
673| $parts['port'] = 9200;
Exception trace:
1 Elasticsearch\ClientBuilder::extractURIParts("http://")
/var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:625
2 Elasticsearch\ClientBuilder::buildConnectionsFromHosts()
/var/www/html/renthisto/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ClientBuilder.php:562
Please use the argument -v to see more details. Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1`
Here's my composer file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"doctrine/dbal": "^2.8",
"elasticsearch/elasticsearch": "^6.0",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/mongodb": "^3.4",
"laravel/framework": "5.6.*",
"laravel/passport": "^7.0",
"laravel/tinker": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
I didn't find any solution to this. I have following version (PHP-7.2) (Laravel-5.6) (Elasticsearch-6.4) in my local system. And I'm using ubuntu 16.04. Thanks in advance.
@agarwal-g2 I've been struggling with the same issue, but I could solve it by configuring it in Laravel (add hosts, register the provider)
This article might help you too: https://madewithlove.be/how-to-integrate-your-laravel-app-with-elasticsearch/
For anyone coming from a Google search, I fixed this by adding the following to my .env:
SEARCH_ENABLED=true
SEARCH_HOSTS=localhost:9200
FYI in my case i could fix it by doing a php artisan config:clear and NOT doing a config:cache (maybe the cached version of the config somehow messes of the elasticsearch host settings)
This issue seems to be resolved, read the comments.
This issue seems to be resolved, read the comments.
where is comment?
@vahidalvandi read above in the PR, here: https://github.com/elastic/elasticsearch-php/issues/812#issuecomment-445444512, https://github.com/elastic/elasticsearch-php/issues/812#issuecomment-472394859, https://github.com/elastic/elasticsearch-php/issues/812#issuecomment-480326684
Most helpful comment
For anyone coming from a Google search, I fixed this by adding the following to my .env:
SEARCH_ENABLED=true
SEARCH_HOSTS=localhost:9200