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.
Update and Revert Version To update the composer to the latest version, simply run the "self-update" command, and to revert back to the previous version do pass in the --rollback.
Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer. json via rm -rf vendor && composer update -v when troubleshooting, excluding any possible interferences with existing vendor installations or composer. lock entries.
update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.
composer update is mostly used in the 'development' phase, to upgrade our project packages. composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer.
How to revert an update? Easy: Restore the composer.lock
file from your version control system that was used before you updated.
The composer.lock
exactly 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.
Running composer install
will always install the software versions recorded in composer.lock
, it will only act like update
if this file is not present.
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.8
is equivalent to >=1.8 <2.0.0
and likewise ~1.9
is the same as >=1.9 <2.0.0
. In other words, ~1.8
will return the SAME THING as ~1.9
if the latest version is >=1.9
. If you really want to use version 1.8
, just do this:
"danielstjules/stringy": "1.8",
That will get EXACTLY version 1.8
. Of course you'll need to run composer update
afterwards.
I find the composer versioning syntax tricky to remember myself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With