LoginSignup
11
12

More than 3 years have passed since last update.

Mac Laravelの環境構築時にエラーが出た話 vol.1

Last updated at Posted at 2020-02-29

目的

  • 環境構築のlaravelインストール時にでたとあるエラーの解決方法をまとめる

エラー概要

  • 下記の手順を参考に環境構築を進めていた。
  • laravelインストール時に下記のエラーが発生した。

    $ composer global require laravel/installer
    Changed current directory to /Users/shun/.composer
    Using version ^3.0 for laravel/installer
    ./composer.json has been created
    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
        - laravel/installer v3.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
        - laravel/installer v3.0.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
        - Installation request for laravel/installer ^3.0 -> satisfiable by laravel/installer[v3.0.0, v3.0.1].
    
    Installation failed, deleting ./composer.json.
    
  • エラー内容の和訳を下記に記載する。

    現在のディレクトリを/Users/shun/.composerに変更しました
    laravel / installerにバージョン^ 3.0を使用する
    ./composer.jsonが作成されました
    コンポーザリポジトリにパッケージ情報をロードする
    依存関係の更新(require-devを含む)
    要件をインストール可能なパッケージのセットに解決できませんでした。
    
       問題1
         -laravel / installer v3.0.1にはext-zipが必要です*->要求されたPHP拡張zipがシステムにありません。
         -laravel / installer v3.0.0にはext-zipが必要です*->要求されたPHP拡張zipがシステムにありません。
         -laravel / installer ^ 3.0のインストール要求-> laravel / installer [v3.0.0、v3.0.1]で満足できる。
    
    インストールが失敗し、。/ composer.jsonが削除されました。
    

原因

  • HomebrewでPHPがインストールできていないことがわかった。
  • エラーから「ext-zip」と言うものが足りないことがわかった。

解決方法

  1. HomebrewでのPHPのインストール

    1. 下記コマンドを実行してPHP7.4をインストールする。

      • 下記コマンドでエラーが出た方はこちら
      $ brew install php@7.4
      
    2. 再度問題のコマンドを実行する。

      $ composer global require laravel/installer
      
    3. 問題なく実行できた。下記に参考のために$ composer global require laravel/installer実行時の出力を記載する。

      Changed current directory to /Users/shun/.composer
      Using version ^3.0 for laravel/installer
      ./composer.json has been created
      Loading composer repositories with package information
      Updating dependencies (including require-dev)
      Package operations: 14 installs, 0 updates, 0 removals
        - Installing symfony/process (v5.0.4): Downloading (100%)         
        - Installing symfony/polyfill-ctype (v1.14.0): Downloading (100%)         
        - Installing symfony/filesystem (v5.0.4): Downloading (100%)         
        - Installing psr/container (1.0.0): Downloading (100%)         
        - Installing symfony/service-contracts (v2.0.1): Downloading (100%)         
        - Installing symfony/polyfill-php73 (v1.14.0): Downloading (100%)         
        - Installing symfony/polyfill-mbstring (v1.14.0): Downloading (100%)         
        - Installing symfony/console (v5.0.4): Downloading (100%)         
        - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)         
        - Installing psr/http-message (1.0.1): Downloading (100%)         
        - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)         
        - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
        - Installing guzzlehttp/guzzle (6.5.2): Downloading (100%)         
        - Installing laravel/installer (v3.0.1): 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
12
6

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
11
12