laravel 如何恢复作曲家更新?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33663378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:09:02  来源:igfitidea点击:

How to revert back composer update?

laravelcomposer-php

提问by John Mccandles

Today I ran composer updateand the update broke my site completely. I found in the php.log the following information:

今天我跑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"

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/201000 Firefox/42.0" [2015 年 11 月 11 日星期三 21:01:48] [错误] [客户端 127.7.179.129] PHP 解析错误:语法错误,意外的“函数”(T_FUNCTION),需要标识符(T_STRING)或 \\(T_NS_SEPARATOR)在 /var/lib/openshift/55c481747628e14556000188/app-root/runtime/repo/config/vendor/danielstjules/stringy/tests/CreateTest.php 中第 5 行 72.15.153.139 - - [11/Nov/2011 48 -0500] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0"

Seems that "danielstjules/stringy" is the one to blame. But how can I revert back to an older version (or using a news version?) of this package? I tried to modify composer.lock file, and changed

似乎“danielstjules/stringy”是罪魁祸首。但是我怎样才能恢复到这个包的旧版本(或使用新闻版本?)?我试图修改 composer.lock 文件,并更改

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

to

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

and run composer updateagain, but it gave the information:

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

使用包信息加载 Composer 存储库 更新依赖项(包括 require-dev) 无需安装或更新 编写锁定文件 生成自动加载文件 PHP 解析错误:语法错误,意外的“函数”(T_FUNCTION),需要标识符(T_STRING)或 \(T_NS_SEPARATOR)在 /var/lib/openshift/55c481747628e14556000188/app-root/runtime/repo/config/vendor/danielstjules/stringy/tests/CreateTest.php 中的第 5 行脚本 php artisan clear-compiled 处理返回的 post-update-cmd 事件一个错误

[RuntimeException] 错误输出:PHP 解析错误:语法错误,意外的“函数”(T_FUNC TION),在 /var/lib/o penshift/55c481747628e14556000188/app-root/runtime/repo 中需要标识符(T_STRING)或 \(T_NS_SEPARATOR) /config/vendor/danie lstjules/stringy/tests/CreateTest.php 第 5 行

How can I rollback this package? Thanks.

我怎样才能回滚这个包?谢谢。

EDIT 2:

编辑2:

composer installwill modify composer.lockautomatically. I modified composer.jsoninstead, and it fetched the old version 1.8 successfully.

composer installcomposer.lock自动修改。我composer.json改为修改,它成功获取了旧版本 1.8。

But the build still failed. This issue descriptionhad the reason. But after I rm -rf test/, the problem was still there.

但是构建仍然失败。这个问题描述是有原因的。但是在我之后rm -rf test/,问题仍然存在。

EDIT 3:

编辑 3:

I tried the following:

我尝试了以下方法:

  1. rm -rf vendor/
  2. composer update
  1. rm -rf vendor/
  2. composer update

The problem was gone.

问题就解决了。

采纳答案by morphatic

If you check the composer version specification documentation, the ~operator gets the latest version that is backwards-compatible according the principles of semantic versioning. That means that ~1.8is equivalent to >=1.8 <2.0.0and likewise ~1.9is the same as >=1.9 <2.0.0. In other words, ~1.8will return the SAME THING as ~1.9if the latest version is >=1.9. If you really want to use version 1.8, just do this:

如果您查看Composer 版本规范文档~操作员将获得根据语义版本控制原则向后兼容的最新版本。这意味着~1.8等价于>=1.8 <2.0.0并且同样~1.9与 相同>=1.9 <2.0.0。换句话说,~1.8将返回相同的东西,就~1.9好像最新版本是>=1.9. 如果您真的想使用 version 1.8,请执行以下操作:

"danielstjules/stringy": "1.8",

That will get EXACTLY version 1.8. Of course you'll need to run composer updateafterwards.

那将得到 EXACTLY 版本1.8。当然,你需要在composer update之后运行。

I find the composer versioning syntax tricky to remember myself.

我发现 Composer 版本控制语法很难记住自己。

回答by Sven

How to revert an update? Easy: Restore the composer.lockfile from your version control system that was used before you updated.

如何恢复更新?简单:composer.lock从更新前使用的版本控制系统恢复文件。

The composer.lockexactly records which software was installed. So it is paramount to commit this file into version control in order to be able to go back to a working version in case of update failure.

composer.lock安装该软件,准确的记录。因此,最重要的是将此文件提交到版本控制中,以便在更新失败的情况下能够返回到工作版本。

Running composer installwill always install the software versions recorded in composer.lock, it will only act like updateif this file is not present.

运行composer install将始终安装 中记录的软件版本composer.lock,仅update当此文件不存在时才会起作用。