How can I upgrade Carbon with Laravel 5.6?
I don't recommend doing this without extreme caution because there may be a reason why Laravel, or any of your other dependencies, require a very strict version of a package.
With that said, Composer does include a neat trick to alias versions to get around this by specifying an alias version in composer.json
:
"require": { ... "nesbot/carbon": "1.32.0 as 1.25.0"},
Note the as 1.25.0
which will trick other packages into thinking 1.32.0
is equivalent to 1.25.0
for dependencies. This trick requires exact versions.
Carbon 2 is officially supported by Laravel since the version 5.8, if you want to use it on a lower version, you can follow those steps:
Set explicitly the Carbon version and add the adapter in your composer.json:
{"require": { "nesbot/carbon": "2.21.3 as 1.34.0" }}