Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot upgrade Carbon 1 to Carbon 2

I've been working on a Laravel project. When I run composer command, I always got warned,

Carbon 1 is deprecated, see how to migrate to Carbon 2. https://carbon.nesbot.com/docs/#api-carbon-2 You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.

Then I run the ./vendor/bin/upgrade-carbon but I got error,

Uncaught Error: Class 'Composer\Composer' not found in .../vendor/nesbot/carbon/src/Carbon/Upgrade.php:131

I have also try to search for solutions but it cant be found. I really need help to continue my project. Thanks a lot.

like image 997
Hikaru Shindo Avatar asked Aug 08 '19 08:08

Hikaru Shindo


1 Answers

add the following dependencies to your composer.json**:

{
  ...
  "require": {
    ...
    "kylekatarnls/laravel-carbon-2": "^1.0.0",
    "nesbot/carbon": "2.0.0-beta.2 as 1.25.0"
  }
  ...
}

then run:

composer update
like image 75
Deepak Avatar answered Sep 28 '22 10:09

Deepak