mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
909 stars 187 forks source link

Installation error #109

Closed ManouLabs closed 2 years ago

ManouLabs commented 3 years ago

I got this while installing

Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking cviebrock/laravel-elasticsearch (8.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing cviebrock/laravel-elasticsearch (8.0.2): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   TypeError

  Return value of Cviebrock\LaravelElasticsearch\Manager::getDefaultConnection() must be of the type string, null returned

  at C:\xampp\htdocs\celeste\vendor\cviebrock\laravel-elasticsearch\src\Manager.php:74
     70▕      * @return string
     71▕      */
     72▕     public function getDefaultConnection(): string
     73▕     {
  ➜  74▕         return $this->app['config']['elasticsearch.defaultConnection'];
     75▕     }
     76▕
     77▕     /**
     78▕      * Set the default connection.

  1   C:\xampp\htdocs\celeste\vendor\cviebrock\laravel-elasticsearch\src\Manager.php:56
      Cviebrock\LaravelElasticsearch\Manager::getDefaultConnection()

  2   C:\xampp\htdocs\celeste\vendor\cviebrock\laravel-elasticsearch\src\ServiceProvider.php:54
      Cviebrock\LaravelElasticsearch\Manager::connection()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Monica-Ibtikar commented 3 years ago

I have the same problem

cviebrock commented 3 years ago

Did you publish the configuration file?

Monica-Ibtikar commented 3 years ago

Did you publish the configuration file?

I got the error on installing the package by composer and because of the error the package won't be installed

cviebrock commented 3 years ago

Which version of Laravel are you using? I just tried a fresh project, and I didn't get the same error as you.

> composer create-project laravel/laravel laravel8
...
> cd laravel8
> composer require cviebrock/laravel-elasticsearch

Can you try the above and see what you get?

Maybe it's a XAMPP issue (I don't have a Windows machine handy for testing).

internetbug256 commented 3 years ago

Hi there. It's happening to me too. I am using latest Laravel 8.x, on a Linux machine.

Error is exactly the same. I even tried to create the config/elasticsearch.php file BEFORE running composer, and got exactly the same error...

Do I have to install previously some other composer package related to Elasticsearch?

Mushood commented 3 years ago

Same issue on windows homestead

vagrant@homestead ~/code/bcu/docker-bcu (master) $ sudo docker exec -it bcu-bcu composer require cviebrock/laravel-elasticsearch
Using version ^8.0 for cviebrock/laravel-elasticsearch
./composer.json has been updated
Running composer update cviebrock/laravel-elasticsearch
Loading composer repositories with package information
Updating dependencies
Lock file operations: 5 installs, 0 updates, 0 removals
  - Locking cviebrock/laravel-elasticsearch (8.0.4)
  - Locking elasticsearch/elasticsearch (v7.12.0)
  - Locking ezimuel/guzzlestreams (3.0.1)
  - Locking ezimuel/ringphp (1.1.2)
  - Locking react/promise (v2.8.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
  - Installing react/promise (v2.8.0): Extracting archive
  - Installing ezimuel/guzzlestreams (3.0.1): Extracting archive
  - Installing ezimuel/ringphp (1.1.2): Extracting archive
  - Installing elasticsearch/elasticsearch (v7.12.0): Extracting archive
  - Installing cviebrock/laravel-elasticsearch (8.0.4): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   TypeError

  Cviebrock\LaravelElasticsearch\Manager::getDefaultConnection(): Return value must be of type string, null returned

  at vendor/cviebrock/laravel-elasticsearch/src/Manager.php:74
     70▕      * @return string
     71▕      */
     72▕     public function getDefaultConnection(): string
     73▕     {
  ➜  74▕         return $this->app['config']['elasticsearch.defaultConnection'];
     75▕     }
     76▕
     77▕     /**
     78▕      * Set the default connection.

      +21 vendor frames
  22  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

The way i fixed it is to create a config/elasticsearch.php AND deleting the files in bootstrap/cache

cviebrock commented 2 years ago

Closing old tickets.