🍉

Class 'Vluzrmos\SlackApi\SlackApiServiceProvider' not found

2023/11/30に公開

composer installするとこうなった。

- Installing squizlabs/php_codesniffer (3.7.2): Extracting archive
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package laravelcollective/html is abandoned, you should avoid using it. Use spatie/laravel-html instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class App\Services\lineService located in ./app/Services/LineService.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In ProviderRepository.php line 208:

  Class 'Vluzrmos\SlackApi\SlackApiServiceProvider' not found

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

composer installというのは、package.jsonに指定されているパッケージをインストールするだけだと思っていたので、特定のクラスを探しにいって見つからない、ということが起こったことを不審に思った。

原因はこの箇所。

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

In ProviderRepository.php line 208:

@php artisan package:discover --ansiというコマンドでは、サービスプロバイダの読み込みをおこなっている。config/app.php に記載されたサービスプロバイダを読み込もうとして、存在しない Vluzrmos\SlackApi\SlackApiServiceProvider クラスを探している。

composer固有の動作ではなく、artisanコマンドを使用した際のエラーだったよう。

config/app.php

Barryvdh\Debugbar\ServiceProvider::class,

        /*
         * Slack API Service Providers...
         */
        Vluzrmos\SlackApi\SlackApiServiceProvider::class,
    ],

SlackApiがある。

個別にインストールしたら成功。

/work/backend# composer require vluzrmos/slack-api
Using version ^0.5.8 for vluzrmos/slack-api
./composer.json has been updated
Running composer update vluzrmos/slack-api
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package laravelcollective/html is abandoned, you should avoid using it. Use spatie/laravel-html instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class App\Services\lineService located in ./app/Services/LineService.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-debugbar
(・・・)
Discovered Package: vluzrmos/slack-api
Package manifest generated successfully.
84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Discussion