在执行 php artisan package:discover –ansi 时,报错:Exception : Please install the Elasticsearch PHP client: elasticsearch/elasticsearch.

1、在执行 php artisan package:discover –ansi 时,报错:Exception : Please install the Elasticsearch PHP client: elasticsearch/elasticsearch.。如图1

在执行 php artisan package:discover --ansi 时,报错:Exception  : Please install the Elasticsearch PHP client: elasticsearch/elasticsearch.

图1

PS E:/wwwroot/wshop/platform> 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/wshop/platform/tests/Feature/ApiCartPaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests/Feature/LoginApiPostCartTest located in E:/wwwroot/wshop/platform/tests/Feature/ApiCartTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests/Feature/LoginGetPaymentTest located in E:/wwwroot/wshop/platform/tests/Feature/PaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Sofa/Eloquence/Searchable/Searchable located in E:/wwwroot/wshop/platform/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/wshop/platform/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/wshop/platform/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/wshop/platform/vendor/tamayo/laravel-scout-elastic/src/LaravelScoutElasticProvider.php:18

  2   Tamayo/LaravelScoutElastic/LaravelScoutElasticProvider::boot()
      E:/wwwroot/wshop/platform/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、原因在于包 tamayo/laravel-scout-elastic 需要安装 elasticsearch/elasticsearch。但是,在执行命令 composer require nuwave/lighthouse 之前,也执行了命令:php artisan package:discover –ansi,未报错的。如图2

原因在于包 tamayo/laravel-scout-elastic 需要安装 elasticsearch/elasticsearch。但是,在执行命令 composer require nuwave/lighthouse 之前,也执行了命令:php artisan package:discover --ansi,未报错的

图2

3、深入分析,在执行命令 composer require nuwave/lighthouse 时,安装了包 tamayo/laravel-scout-elastic,即包 tamayo/laravel-scout-elastic 被写入了 composer.lock 文件,而在执行命令 composer require nuwave/lighthouse 之前,composer.lock 文件中不存在包 tamayo/laravel-scout-elastic。如图3

深入分析,在执行命令 composer require nuwave/lighthouse 时,安装了包 tamayo/laravel-scout-elastic,即包 tamayo/laravel-scout-elastic 被写入了 composer.lock 文件,而在执行命令 composer require nuwave/lighthouse 之前,composer.lock 文件中不存在包 tamayo/laravel-scout-elastic

图3

4、由此得出结论,composer.lock 与 composer.json 文件并未严格保持一致。在执行命令 composer require nuwave/lighthouse 时,才让 composer.lock 与 composer.json 文件保持了一致性。

5、执行命令:composer require elasticsearch/elasticsearch 后,在执行 php artisan package:discover –ansi 时,不再报错。

PS E:/wwwroot/wshop/platform> 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/wshop/platform/tests/Feature/ApiCartPaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests/Feature/LoginApiPostCartTest located in E:/wwwroot/wshop/platform/tests/Feature/ApiCartTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Tests/Feature/LoginGetPaymentTest located in E:/wwwroot/wshop/platform/tests/Feature/PaymentTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Sofa/Eloquence/Searchable/Searchable located in E:/wwwroot/wshop/platform/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/wshop/platform/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: newshop/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!

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250717.html

(0)
上一篇 2022年5月1日
下一篇 2022年5月1日

相关推荐

发表回复

登录后才能评论