When executing php artisan package:discover –ansi, an error is reported: Exception : Please install the Elasticsearch PHP client: Elasticsearch/elasticsearch.
1. When executing php artisan package:discover –ansi, the error: please install the elasticsearch php client: Elasticsearch/Elasticsearch. as shown in Figure 1
PS E:\wwwroot\object> composer require nuwave/lighthouse
Using version ^5.39 for nuwave/lighthouse
./composer.json has been updated
Running composer update nuwave/lighthouse
Loading composer repositories with package information
Updating dependencies
Lock file operations: 11 installs, 0 updates, 0 removals
- Locking barryvdh/laravel-debugbar (v3.6.7)
- Locking haydenpierce/class-finder (0.4.3)
- Locking laragraph/utils (v1.3.0)
- Locking laravel/scout (v8.6.1)
- Locking maximebf/debugbar (v1.18.0)
- Locking nuwave/lighthouse (v5.39.2)
- Locking respect/stringifier (0.2.0)
- Locking respect/validation (2.2.3)
- Locking tamayo/laravel-scout-elastic (8.0.3)
- Locking thecodingmachine/safe (v1.3.3)
- Locking webonyx/graphql-php (v14.11.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
- Downloading maximebf/debugbar (v1.18.0)
- Downloading barryvdh/laravel-debugbar (v3.6.7)
- Downloading webonyx/graphql-php (v14.11.5)
- Downloading nuwave/lighthouse (v5.39.2)
- Downloading respect/stringifier (0.2.0)
- Downloading respect/validation (2.2.3)
- Downloading laravel/scout (v8.6.1)
- Downloading tamayo/laravel-scout-elastic (8.0.3)
- Installing maximebf/debugbar (v1.18.0): Extracting archive
- Installing barryvdh/laravel-debugbar (v3.6.7): Extracting archive
- Installing webonyx/graphql-php (v14.11.5): Extracting archive
- Installing thecodingmachine/safe (v1.3.3): Extracting archive
- Installing laragraph/utils (v1.3.0): Extracting archive
- Installing haydenpierce/class-finder (0.4.3): Extracting archive
- Installing nuwave/lighthouse (v5.39.2): Extracting archive
- Installing respect/stringifier (0.2.0): Extracting archive
- Installing respect/validation (2.2.3): Extracting archive
- Installing laravel/scout (v8.6.1): Extracting archive
- Installing tamayo/laravel-scout-elastic (8.0.3): Extracting archive
10 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.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Google\Task\Composer::cleanup
Class Tests\Feature\LoginApiPostCartPaymentTest located in E:/wwwroot/object/tests\Feature\ApiCartPaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests\Feature\LoginApiPostCartTest located in E:/wwwroot/object/tests\Feature\ApiCartTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests\Feature\LoginGetPaymentTest located in E:/wwwroot/object/tests\Feature\PaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Sofa\Eloquence\Searchable\Searchable located in E:/wwwroot/object/vendor/sofa/eloquence-base/src\Contracts\Searchable\Searchable.php does not comply with psr-4 autoloading standard. Skipping.
Class Modules\ThemeStore\Tests\FactoryTest located in E:/wwwroot/object/Modules\ThemeStore\Tests\Unit\FactoryTest.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Exception : Please install the Elasticsearch PHP client: elasticsearch/elasticsearch.
at E:\wwwroot\object\vendor\tamayo\laravel-scout-elastic\src\LaravelScoutElasticProvider.php:42
38| if (class_exists(ClientBuilder::class)) {
39| return;
40| }
41|
> 42| throw new Exception('Please install the Elasticsearch PHP client: elasticsearch/elasticsearch.');
43| }
44| }
45|
Exception trace:
1 Tamayo\LaravelScoutElastic\LaravelScoutElasticProvider::ensureElasticClientIsInstalled()
E:\wwwroot\object\vendor\tamayo\laravel-scout-elastic\src\LaravelScoutElasticProvider.php:18
2 Tamayo\LaravelScoutElastic\LaravelScoutElasticProvider::boot()
E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
2. The reason is that the package tamayo/laravel-scout-elastic needs to install Elasticsearch/elasticsearch. However, before executing the command composer require nuwave/lighthouse, the command is also executed: php artisan package:discover –ansi, no error is reported. as shown in Figure 2
3. In-depth analysis, when executing the command composer require nuwave/lighthouse, the package tamayo/laravel-scout-elastic is installed, that is, the package tamayo/laravel-scout-elastic is written to the composer.lock file, and before executing the command composer require nuwave/lighthouse, composer.lock The package tamayo/laravel-scout-elastic does not exist in the file. as shown in Figure 3
4. From this, it is concluded that the composer.lock and the composer.json file are not strictly consistent. The composer.lock is consistent with the composer.json file only when executing the command composer require nuwave/lighthouse .
5. Execute the command: After composer require elasticsearch/elasticsearch, when executing php artisan package:discover –ansi, an error will not be reported.
PS E:\wwwroot\object> composer require elasticsearch/elasticsearch
Using version ^8.0 for elasticsearch/elasticsearch
./composer.json has been updated
Running composer update elasticsearch/elasticsearch
Loading composer repositories with package information
Updating dependencies
Lock file operations: 4 installs, 0 updates, 0 removals
- Locking elasticsearch/elasticsearch (v8.0.0)
- Locking ezimuel/guzzlestreams (3.0.1)
- Locking ezimuel/ringphp (1.2.0)
- Locking react/promise (v2.9.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
- Downloading react/promise (v2.9.0)
- Downloading ezimuel/guzzlestreams (3.0.1)
- Downloading ezimuel/ringphp (1.2.0)
- Downloading elasticsearch/elasticsearch (v8.0.0)
- Installing react/promise (v2.9.0): Extracting archive
- Installing ezimuel/guzzlestreams (3.0.1): Extracting archive
- Installing ezimuel/ringphp (1.2.0): Extracting archive
- Installing elasticsearch/elasticsearch (v8.0.0): Extracting archive
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Google\Task\Composer::cleanup
Class Tests\Feature\LoginApiPostCartPaymentTest located in E:/wwwroot/object/tests\Feature\ApiCartPaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests\Feature\LoginApiPostCartTest located in E:/wwwroot/object/tests\Feature\ApiCartTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests\Feature\LoginGetPaymentTest located in E:/wwwroot/object/tests\Feature\PaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Sofa\Eloquence\Searchable\Searchable located in E:/wwwroot/object/vendor/sofa/eloquence-base/src\Contracts\Searchable\Searchable.php does not comply with psr-4 autoloading standard. Skipping.
Class Modules\ThemeStore\Tests\FactoryTest located in E:/wwwroot/object/Modules\ThemeStore\Tests\Unit\FactoryTest.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: arubacao/asset-cdn
Discovered Package: axlon/laravel-postal-code-validation
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: beyondcode/laravel-er-diagram-generator
Discovered Package: boaideas/laravel-cli-create-user
Discovered Package: cviebrock/eloquent-sluggable
Discovered Package: dingo/api
Discovered Package: fideloper/proxy
Discovered Package: genealabs/laravel-model-caching
Discovered Package: igaster/laravel-theme
Discovered Package: ignited/laravel-omnipay
Discovered Package: intervention/image
Discovered Package: jenssegers/agent
Discovered Package: jgrossi/corcel
Discovered Package: laravel/passport
Discovered Package: laravel/scout
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: maatwebsite/excel
Discovered Package: mavinoo/laravel-batch
Discovered Package: nesbot/carbon
Discovered Package: newobject/facebook-conversions-api
Discovered Package: nunomaduro/collision
Discovered Package: nuwave/lighthouse
Discovered Package: nwidart/laravel-modules
Discovered Package: orangehill/iseed
Discovered Package: overtrue/laravel-pinyin
Discovered Package: overtrue/laravel-wechat
Discovered Package: prettus/l5-repository
Discovered Package: s-ichikawa/laravel-sendgrid-driver
Discovered Package: sentry/sentry-laravel
Discovered Package: silber/page-cache
Discovered Package: socialiteproviders/manager
Discovered Package: sofa/eloquence-base
Discovered Package: sofa/eloquence-mutable
Discovered Package: spatie/laravel-activitylog
Discovered Package: spatie/laravel-permission
Discovered Package: spatie/laravel-query-builder
Discovered Package: spatie/laravel-sitemap
Discovered Package: tamayo/laravel-scout-elastic
Discovered Package: torann/geoip
Package manifest generated successfully.
113 packages you are using are looking for funding.
Use the `composer fund` command to find out more!


