34
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP8 と Laravel8 で league/flysystem-aws-s3-v3 をインストールするときにハマった

Last updated at Posted at 2021-03-27

Laravel で AWS S3 を操作したい時

AWS S3を操作する時はこの thephpleague/flysystem-aws-s3-v3 ライブラリを利用します。

環境

  • PHP: 8.0.2
  • Laravel: 8.34.0

league/flysystem-aws-s3-v3 インストール時にエラー

$ composer require league/flysystem-aws-s3-v3
Using version ^2.0 for league/flysystem-aws-s3-v3
./composer.json has been updated
Running composer update league/flysystem-aws-s3-v3
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - league/flysystem-aws-s3-v3[2.0.0, ..., 2.x-dev] require league/flysystem ^2.0.0 -> found league/flysystem[2.0.0-alpha.1, ..., 2.x-dev] but the package is fixed to 1.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - league/flysystem-aws-s3-v3[2.0.0-alpha.1, ..., 2.0.0-RC1] require php ^7.2 -> your php version (8.0.2) does not satisfy that requirement.
    - Root composer.json requires league/flysystem-aws-s3-v3 ^2.0 -> satisfiable by league/flysystem-aws-s3-v3[2.0.0-alpha.1, ..., 2.x-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

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

リリースを見てみると、現在の最新バージョン(2021.03.27)は、2.0.4です。
thephpleague/flysystem-aws-s3-v3のv2系を利用する場合、thephpleague/flysystemの2系をインストールする必要があるようです。

thephpleague/flysystemの現在の最新バージョン(2021.03.27)は、2.0.4です。

Laravelフレームワークが利用しているthephpleague/flysystemのバージョンを見てみましょう。

composer.json
    "require": {
        "league/flysystem": "^1.1",
    },

Laravelフレームワークがleague/flysystemの1系を参照しているので、thephpleague/flysystem-aws-s3-v3の2系をインストールしようとするとエラーになってしまうという原因でした。

league/flysystemのv2はいつ対応されるのか?

Laravel9.xからleague/flysystemのv2がサポートされます。

公式ドキュメント

  • Amazon S3: league/flysystem-aws-s3-v3 ~1.0

公式ドキュメントを見ると1系をインストールするようにとのこと。
(まぁ最初に見ろよって話ですが...)

解決

$ composer require league/flysystem-aws-s3-v3:^1.0
34
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?