【问题标题】:How to install Composer on macOS?如何在 macOS 上安装 Composer?
【发布时间】:2019-01-10 10:04:29
【问题描述】:

我试图在我的 macOS 版本上安装 Composer:high sierra--> 10.13.4

但使用命令后:

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 

它创建了一些文件和目录,但没有下载作曲家。 我的终端显示以下错误:

未启用日志处理 - 使用 stderr 日志记录

创建的目录:/var/db/net-snmp

创建的目录:/var/db/net-snmp/mib_indexes`

我该如何解决这个问题?

【问题讨论】:

    标签: php macos shell composer-php


    【解决方案1】:
    1. 在 Mac 终端中安装 Brew

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    1. 安装 Composer

    brew install composer

    1. 检查作曲家

    composer -v

    【讨论】:

      【解决方案2】:

      首先在您的 MAC 上安装 Brew:

      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
      

      然后安装PHP:

      brew update
      brew install php
      brew install composer
      

      要测试安装,请运行:

       $ composer -V
      

      【讨论】:

      • 显示错误:1。错误:自制/欺骗已被弃用。这个水龙头现在是空的,因为它的所有公式都被迁移了。 2. 错误:homebrew/php 已被弃用。此水龙头现在是空的,因为它的所有公式都已迁移。
      • homebrew/dupes 现在是核心的一部分 - stackoverflow.com/questions/45124717/… 与 homebrew/php github.com/weprovide/valet-plus/issues/127 相同
      • 我在这些命令之上尝试了composer update --ignore-platform-reqs,它成功了
      【解决方案3】:
      Install download the composer using the following curl  command in the 
      terminal:
      
      curl -sS https://getcomposer.org/installer | php
      
      After the command, you will have composer.phar file in the current 
      directory and the composer command is available as:
      
      php composer.phar [composer commnad]
      
      In order to make composer available globally, you have to move the 
      recently downloaded composer.phar to local user’s bin folder as follow:
      
      go to /usr/local/bin folder . You can click  Shift + Command + G to open 
      the dialog to go to folder.
      
      move the recently downloaded composer.phar in the usr/local/bin folder
      create a alias using command  alias composer="php 
       /usr/local/bin/composer.phar"
      
      
      Now, you can access the composer from the terminal simply using the 
      composer  command. Thats it.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-07
        • 2021-09-19
        • 2011-07-26
        • 2019-05-10
        • 2017-08-25
        • 2013-02-03
        • 2017-12-11
        相关资源
        最近更新 更多