Today I ran composer update and the update broke my site completely. I found in the php.log the following information:
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"
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
"require": {
"danielstjules/stringy": "~1.8",
to
"require": {
"danielstjules/stringy": "~1.9",
and run composer update again, but it gave the information:
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
How can I rollback this package? Thanks.
EDIT 2:
composer install will modify composer.lock automatically. I modified composer.json instead, and it fetched the old version 1.8 successfully.
But the build still failed. This issue description had the reason. But after I rm -rf test/, the problem was still there.
EDIT 3:
I tried the following:
rm -rf vendor/composer update
The problem was gone.
composer.lockfile?composer.lockshould be in version control. That'd allow you to just revert the changes to it, then docomposer installto reinstall the known functional versions.composer.lockwithout using~character. If still broken, we have to using GIT or SVN to revert back to previous revision absolutely.composer.lockin any way. If you don't trust Composer to create a (according to version requirements) valid set of software packages, who should be able to do this? If there are versions that you want to avoid, modifycomposer.jsonto explicitly exclude them, then runupdateagain. Or roll back to the previous set of versions.composer.jsoninstead. Thanks.