composer wamp multi version (when install module error)

 問題:我電腦有原先有一個wamp,但是PHP版本為5.5,不能滿足Laravel的版本需求,所以我重新下載了最新版的wamp,我安裝了最新版的wamp,用composer提示PHP版本低


解決方法:

我退出了原來的wamp,啟用最新的wamp(含php7),但還是不能用composer install初始化我的Laravel專案。

1) 在win cmd下執行php – version顯示為原來的版本5.5。好吧,其實已經有答案了,一開始沒有反應過來,這個5.5是因為我配置了環境變量,所以一直指向我原來的PHP目錄,導致composer失敗

2)解決方案:在我的电脑->属性->高级->环境变量中添加最新的PHP版本為環境變量,但是必須在之前環境變量的前面,當然也可以把之前的PHP環境變量刪除

3)重啟cmd或phpstorm運行composer install就可以了



143


You can change php version of composer without uninstalling it, follow these steps :


Search for system environment variables in cortana.

Click on the button "Environment variables".

Under "System variables" select path and click on edit, you will see one entry like this "C:\wamp\bin\php\php5.6.13".

Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here php7.1.9 is folder name.

Replace php5.6.13 with bin7.1.9, it will look like these "C:\wamp\bin\php\php7.1.9", just click ok on all the boxes.

You are done.

To verify, first close all the cmd windows, than open cmd and type php -v, press enter and you should see php7.1.9.

If you don't see change in php version than just restart your pc and run php -v again in cmd , it will work.

留言

此網誌的熱門文章

Install Drupal 10 with composer in XAMPP htdocs OR PHP Command

fix drupal 11 install error

[custom block module]Correcting Heredoc Syntax and Attaching JS