作曲家& Cygwin [英] Composer & Cygwin

查看:292
本文介绍了作曲家& Cygwin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您尝试在全局安装,Composer在Cygwin中无法正常运行。

Composer doesn't run correctly in Cygwin if you try to install it "globally".

将composer.phar放入/ usr / local / bin /那么尝试运行它将导致错误:

Putting composer.phar into /usr/local/bin/composer, then trying to run it will result in the error:

Could not open input file: /usr/local/bin/composer


推荐答案

刚刚跳过相同的问题,

Just tripped over the same problem and found a solution. Posting it here, just in case I'll ever have to look it up again.


  1. 设置 bin 目录正下方 / home / my-username

cd ~
mkdir bin


  • code> composer.phar (或其他任何一个漂亮的新PHP phs正在兴起)
    〜/ bin 目录,并确保设置 执行位

  • Move the composer.phar (or any other of those nifty new PHP imps that are on the rise) into the ~/bindirectory and make sure to set it's execution bit:

    # Notice how I got rid of the superfluous `.phar` extension
    mv /path/to/composer.phar ~/bin/composer
    chmod +x ~/bin/composer
    


  • 告诉 cygwin ,将〜/ bin 目录:

    打开文件〜/ .bash_profile 并取消注释以下段落...

    Open up the file ~/.bash_profile and uncomment the following paragraph ...

    # Set PATH so it includes user's private bin if it exists
    if [ -d "${HOME}/bin" ] ; then
      PATH="${HOME}/bin:${PATH}"
    fi
    


  • 现在,对于最重要的部分:

  • Now, for the most important part:

    一个包装脚本,帮助Win的本地PHP解析Unix风格的路径问题毕竟作为Windows不知道如何处理 / cygdrive /...路径)。

    A wrapper script that helps Win's native PHP resolve Unix style paths (which is causing the problem after all as Windows doesn't know how to handle /cygdrive/... paths).

    cd ~/bin
    touch php
    chmod +x php
    


    b $ b

    编辑包装程序脚本〜/ bin / php 后应该读为:

    #!/bin/bash
    
    # e.g. php="/cygdrive/c/Program Files (x86)/php/php.exe"
    php="/path/to/php.exe"
    
    for ((n=1; n <= $#; n++)); do
        if [ -e "${!n}" ]; then
            # Converts Unix style paths to Windows equivalents
            path="$(cygpath --mixed ${!n} | xargs)"
    
            case 1 in
                $(( n == 1 )) )
                    set -- "$path" "${@:$(($n+1))}";;
                $(( n < $# )) )
                    set -- "${@:1:$((n-1))}" "$path" ${@:$((n+1)):$#};;
                *)
                    set -- "${@:1:$(($#-1))}" "$path";;
            esac
        fi
    done
    
    "$php" "$@"
    


  • 现在重新启动你的shell,它应该正确地调用PHP解释器,当
    绊到一个#!/ usr / bin / env php shebang。只需发出:

  • Now restart your shell and it should correctly invoke the PHP interpreter whenever it stumbles upon a #!/usr/bin/env php shebang. Simply issue a:

    composer --help
    


  • 这篇关于作曲家&amp; Cygwin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆