2015-11-12 64 views
6

今天我跑了composer update,更新完全破壞了我的網站。我在php.log發現如下信息:如何恢復作曲家更新?

72.15.153.139 - - [11/Nov/2015:21:01:45 -0500] "GET/HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0" [Wed Nov 11 21:01:48 2015] [error] [client 127.7.179.129] PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) in /var/lib/openshift/55c481747628e14556000188/app-root/runtime/repo/config/vendor/danielstjules/stringy/tests/CreateTest.php on line 5 72.15.153.139 - - [11/Nov/2015:21:01:48 -0500] "GET/HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0"

似乎「danielstjules /粘性」是難辭其咎的一個。但是我怎樣才能恢復到這個軟件包的舊版本(或使用新聞版本?)?我試圖修改composer.lock文件,並改變

  "require": { 
      "danielstjules/stringy": "~1.8", 

 "require": { 
      "danielstjules/stringy": "~1.9", 

,並再次運行composer update,但它給了信息:

Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Writing lock file Generating autoload files PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \ (T_NS_SEPARATOR) in /var/lib/openshift/55c481747628e14556000188/app-root/runtime/repo/config/vendor/danielstjules/stringy/tests/CreateTest.php on line 5 Script php artisan clear-compiled handling the post-update-cmd event returned with an error

[RuntimeException] Error Output: PHP Parse error: syntax error, unexpected 'function' (T_FUNC TION), expecting identifier (T_STRING) or \ (T_NS_SEPARATOR) in /var/lib/o penshift/55c481747628e14556000188/app-root/runtime/repo/config/vendor/danie lstjules/stringy/tests/CreateTest.php on line 5

我如何可以回滾該包?謝謝。

編輯2:

composer install將自動修改composer.lock。相反,我修改了composer.json,它成功讀取了舊版本1.8。

但構建仍然失敗。原因是This issue description。但是在rm -rf test/之後,問題仍然存在。

編輯3:

我試過如下:

  1. rm -rf vendor/
  2. composer update

的問題不見了。

+0

你提交了'composer.lock'文件嗎? –

+0

你的'composer.lock'應該在版本控制中。這將允許你恢復對它的更改,然後執行'composer install'來重新安裝已知的功能版本。 – ceejayoz

+0

首先,您應該指定要更新的準確版本。修改'composer.lock'而不使用'〜'字符。如果仍然存在問題,我們必須使用GIT或SVN來完全恢復到之前的修訂版本。 –

回答

3

如果您檢查composer version specification documentation~運營商根據semantic versioning的原則獲得向後兼容的最新版本。這意味着~1.8相當於>=1.8 <2.0.0,同樣~1.9與相同。換句話說,如果最新版本是>=1.9~1.8將返回相同的東西作爲~1.9。如果你真的想使用版本1.8,只是這樣做:

"danielstjules/stringy": "1.8", 

這將得到完全版本1.8。之後你需要運行composer update

我發現作曲家版本化語法很棘手以記住我自己。

27

如何恢復更新?簡單:從更新之前使用的版本控制系統恢復composer.lock文件。

composer.lock正好記錄安裝了哪個軟件。因此,將該文件提交到版本控制中是非常重要的,以便能夠在更新失敗的情況下返回到工作版本。

運行composer install將始終安裝在composer.lock中記錄的軟件版本,如果此文件不存在,它將僅起到update的作用。

+2

這顯然應該是答案。簡單而乾淨。 –

+0

當你失望時,明顯的反應會讓你頭腦發熱 –

+0

爲什麼這不是正確答案?!?! @JohnMccandles – evilReiko