0
0

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.

【超初心者用】Laravelのインストールがうまくいかなかった

Last updated at Posted at 2020-07-21

comporserでlaravelをインストールしようとしたら

$ composer global require "laravel/installer"

Using version ^3.2 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for laravel/installer ^3.2 -> satisfiable by laravel/installer[v3.2.0].
    - laravel/installer v3.2.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.


Installation failed, reverting ./composer.json to its original content.

問題が発生しているらしい

./composer.json has been updated

なんかよくわからないが、バージョンが違うのかな。
先の方を読むと、

Installation request for laravel/installer ^3.2 -> satisfiable by laravel/installer[v3.2.0].

リクエストをlaravel/installer[v3.2.0]に変えればいいよという感じですかね。

laravel/installer v3.2.0 requires ext-zip * -> the requested PHP extension zip is missing from your system
ここは、PHPのextensionのzipが見つからないということでしょうか。

とりあえず、最初の方を試してみる。

laravel/installer[v3.2.0]で実行してもダメ

                                                                                                                     
  [InvalidArgumentException]                                                                                         
  Could not find a matching version of package laravel/installer[v3.2.0]. Check the package spelling, your version   
  constraint and that the package is available in a stability which matches your minimum-stability (stable).         
                                                                                                                     

require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

ext-zipが足りない

laravel/installer v3.2.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.

という記載があるので、laravel/installer v3.2.の要求に関してはext-zipが必要だということですかね。

とりあえずPHPをインストールし直した

$ brew install php

でインストールし直しました

できた!

$ composer global require "laravel/installer"
Changed current directory to /Users/onoharamakoto/.composer
Using version ^3.2 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 19 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-php80 (v1.18.0): Downloading (100%)         
  - Installing symfony/process (v5.1.2): Downloading (100%)         
  - Installing symfony/polyfill-ctype (v1.18.0): Downloading (100%)         
  - Installing symfony/filesystem (v5.1.2): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.18.0): Downloading (100%)         
  - Installing symfony/polyfill-intl-normalizer (v1.18.0): Downloading (100%)         
  - Installing symfony/polyfill-intl-grapheme (v1.18.0): Downloading (100%)         
  - Installing symfony/string (v5.1.2): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing symfony/service-contracts (v2.1.3): Downloading (100%)         
  - Installing symfony/polyfill-php73 (v1.18.0): Downloading (100%)         
  - Installing symfony/console (v5.1.2): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing psr/http-client (1.0.1): Downloading (100%)         
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (7.0.1): Downloading (100%)         
  - Installing laravel/installer (v3.2.0): Downloading (100%)         
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Writing lock file
Generating autoload files
11 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

なんかエラーメッセージが消えました。
どうやらインストールできたようです。

パスを通す

$ vim ~/.bashrc

新しくファイルを作成して開きます。
下の記述を入れる。

export PATH="$HOME/.composer/vendor/bin:$PATH"

:wqで保存して終了する。

次のコマンドを実行する

$ source ~/.bashrc

ここまで来たらLaravelのコマンドが使える

$ laravel
Laravel Installer 3.2.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help  Displays help for a command
  list  Lists commands
  new   Create a new Laravel application

エラーメッセージが出てません。動いているらしい。

ターミナルをいったん閉じると

zsh: command not found: laravel

Laravelのコマンドは使えなくなるみたいです。
もう一度source ~/.bashrcを実行してからやればまた使えるようになりました。

結論

Problem 1
    - Installation request for laravel/installer ^3.2 -> satisfiable by laravel/installer[v3.2.0].
    - laravel/installer v3.2.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.

上記のようなエラーが出た場合は

  1. PHPをインストールし直すbrew install php
  2. composer global require "laravel/installer"を実行してlaravelをインストールする

これで大丈夫みたいです。

真似しないようにお願いします

当方、かなりの素人です。何をやっても一つずつエラーが発生して前に進まないのです。

とりあえず作業を記録しています。自分向けに書いてます。できるだけ他の肩の記事を参考に処理を進めてください。大変なことになるかもしれませんので。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?