huxiaohaiyang
V2EX  ›  问与答

.zshrc 里面实现 PHP 版本切换、或者有什么工具推荐

  •  
  •   huxiaohaiyang · Aug 28, 2019 · 900 views
    This topic created in 2474 days ago, the information mentioned may be changed or developed.

    想在.zshrc 里面实现版本切换

    背景:历史代码需要老版本支持

    环境: macOS

    目前:现在要切换版本要三步,不是很优雅:

      1、php71 || php56
      
      2、修改对应 PHP 版本 export
      
      3、source .zshrc
    

    问题:想一步搞定,这个怎么在.zshrc 里面执行(看这里)

    php_version="php -v|grep 'PHP 7'" 这句貌似没值
    
    
    #php version change
    
    alias php56="brew services stop [email protected] && brew services start [email protected]"
    
    alias php71="brew services stop [email protected] && brew services start [email protected]"  
    
    php_version="php -v|grep 'PHP 7'" 
    
    if [[ $php_version == "" ]]; then
     	export PHP_56_HOME_BIN="/usr/local/opt/[email protected]/bin:$PATH"
    	export PHP_56_HOME_SBIN="/usr/local/opt/[email protected]/sbin:$PATH"
    else
     	export PHP_71_HOME_BIN="/usr/local/opt/[email protected]/bin:$PATH"
    	export PHP_71_HOME_SBIN="/usr/local/opt/[email protected]/sbin:$PATH"
    fi
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2743 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 02:12 · PVG 10:12 · LAX 19:12 · JFK 22:12
    ♥ Do have faith in what you're doing.