欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Carbon 1 is deprecated, see how to migrate to Carbon 2. https://carbon.nesbot.com/docs/#api-carbon-2 有大用


New issue

Carbon 1 deprecated #28679            

 Closed            
jonnott opened this issue on 31 May · 3 comments

Comments

@jonnott                        

commented on 31 May                                    

So, composer is now saying Carbon 1.x is old news...

*******************************************
 /!\ Warning, you're using a deprecated
 ¨¨¨ version of Carbon, we will soon stop
     providing support and update for 1.x
     versions, please upgrade to Carbon 2.
*******************************************

Most features of Carbon 1 are still available in Carbon 2.
See how to migrate: https://carbon.nesbot.com/docs/#api-carbon-2
                                                       

laravel/framework's composer.json states:

"nesbot/carbon": "^1.26.3 || ^2.0"

..but how can we make it choose 2.0.x over 1.x when doing 'composer install' or 'composer update'? And are there any negative side-effects? (my app doesn't use anything in carbon directly which isn't 2.x-compatible). Even if I rm -rf ./vendor and rm composer.lock and then do 'composer install', it still installs 1.x :(

@driesvints                            
Member                                        

commented on 31 May                                        

5.8 currently supports 2.0 so you can just do composer require nesbot/carbon:^2.0 which should work.

@driesvints driesvints closed this on 31 May                            

@jonnott                            
Author                                        

commented on 31 May                                        

@driesvints Thanks.

@kylekatarnls                            
Contributor                                        

commented on 1 Jun                                        

Unless you specify to composer "prefer-lowest", it should take the more recent version. So a simple composer update should be enough to get Carbon 2 unless you have Laravel < 5.8 or other dependencies that requires Carbon 1.

Sign up for free                    
新问题                    

来自 https://github.com/laravel/framework/issues/28679


碳1弃用 #28679            

 关闭            
乔诺特 打开了这个问题                 on 31 May ·3评论            

评论    

@jonnott                        

评论道 on 31 May                                    

所以,作曲家现在说Carbon 1.x是旧闻......                                                        

*******************************************
 /!\ Warning, you're using a deprecated
 ¨¨¨ version of Carbon, we will soon stop
     providing support and update for 1.x
     versions, please upgrade to Carbon 2.
*******************************************

Most features of Carbon 1 are still available in Carbon 2.
See how to migrate: https://carbon.nesbot.com/docs/#api-carbon-2
                                                       

laravel / framework的composer.json声明:                                                        

“nesbot / carbon”:“^ 1.26.3 || ^ 2.0”                                                        

..但是,在进行“作曲家安装”或“作曲家更新”时,我们如何让它在1.x之上选择2.0.x?有没有负面的副作用?(我的应用程序不直接使用任何碳,不兼容2.x)。即使我rm -rf ./vendor和rm composer.lock然后做'composer install',它仍然会安装1.x :(                                                        

@driesvints                            
会员                                        

评论道 on 31 May                                        

5.8目前支持2.0,所以你可以做到composer require nesbot/carbon:^2.0哪些应该工作。                                                            

@driesvints driesvints 关闭了这个 on 31 May                            

@jonnott                            
作者                                        

评论道 on 31 May                                        

@driesvints谢谢。                                                            

@kylekatarnls                            
贡献者                                        

评论道 on 1 Jun                                        

除非你指定作曲家“prefer-lowest”,否则它应该采用更新的版本。所以一个简单的composer update应该足以获得Carbon 2,除非你有Laravel <5.8或其他需要Carbon 1的依赖项。                                                            

来自  https://github.com/laravel/framework/issues/28679


Asked 
Active 1 month ago    
Viewed 2k times
1

Is anyone getting this when running a composer update command?

Local install: Craft CMS 3.1.31

update --no-interaction --ansi
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Nothing to install or update
    Generating optimized autoload files
    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.
    All packages for ./composer.json have been updated.
               
improve this question                            
       

4 Answers

activeoldestvotes                    
       
3

All Solspace plugins use some bit of the Carbon dependency so it's highly likely it might be something like Calendar and/or Freeform triggering this. As of last week, we've updated Freeform 2, Freeform 3 and Express Forms to use ^1.22.1|^2.19 for the requirement, and Calendar will receive the same update this week.

The issue is that Carbon 2 requires PHP 7.1.8+ while Craft 3 requires PHP 7.0+. Carbon 1.x was recently deprecated, but by no means is it unsafe, unstable or risky to use, etc. If we changed it to force Carbon 2, anyone using PHP 7.0 wouldn't be able to use Freeform/Calendar, etc, so we've switched it to ^1.22.1|^2.19 as noted above, meaning that if your site happens to have PHP 7.1.8+ installed, it'll pull the 2.x version of Carbon instead, and you will no longer see the error.

If you happen to have PHP 7.0.x installed on your server, however, it'll always call Carbon 1 and always trigger the error, since there currently is no available version of Carbon that supports PHP 7.0 and is not deprecated.

improve this answer                            
       
2

To find the culprit, you could run a composer show --tree to see which plugin is using the dependency.

So far, I found two plugins using it :

  • rias/craft-contact-form-extensions (1.1.6)

  • solspace/craft3-calendar (2.0.20)

If you're using Solspace calendar, you should consider to upgrade to v3. If you're using Rias Contact form extension, you can try to add the updated dependency to your composer.json file by running a composer require nesbot/carbon. It will fix the warning until the plugin is updated.

improve this answer                            
       
1

Thank you both - It's Freeform 3 (Solspace notified)

enter image description here                        

improve this answer                            
       
0

One of the plugins you have installed is either directly including a Carbon 1 dependency (or indirectly via one of its dependencies).

Whatever is doing it should eventually update to using Carbon 2.

improve this answer                            
       

来自  https://craftcms.stackexchange.com/questions/30714/carbon-1-is-deprecated-migrate-to-carbon-2


 
活跃 1个月前    
浏览次数: 2k次    
1                    

有人在运行composer update命令时得到这个吗?                    

本地安装:Craft CMS 3.1.31                    

update --no-interaction --ansi
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Nothing to install or update
    Generating optimized autoload files
    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.
    All packages for ./composer.json have been updated.
               
改善这个问题                            
       

4答案                

活跃的最老                    
       
3                        

所有Solspace插件都使用了一些Carbon依赖性,所以很可能它会像Calendar和/或Freeform那样触发它。截至上周,我们已经更新了Freeform 2,Freeform 3和Express Forms以^1.22.1|^2.19满足要求,而Calendar将在本周收到相同的更新。                        

问题是Carbon 2需要PHP 7.1.8+而Craft 3需要PHP 7.0+Carbon 1.x最近被弃用,但绝不是不安全,不稳定或使用风险等。如果我们改变它以强制使用Carbon 2,任何使用PHP 7.0的人都将无法使用Freeform / Calendar等,所以我们已经将它切换到^1.22.1|^2.19如上所述,这意味着如果你的网站安装了PHP 7.1.8+,那么它将取代2.x版本的Carbon,你将不再看到错误。                        

但是,如果您的服务器上安装了PHP 7.0.x,它将始终调用Carbon 1并始终触发错误,因为目前没有可用的支持PHP 7.0的Carbon版本不会弃用。                        

改善这个答案                            
       
2                        

要查找罪魁祸首,您可以运行a composer show --tree来查看哪个插件正在使用依赖项。                        

到目前为止,我找到了两个使用它的插件:                        

  • rias / craft-contact-form-extensions(1.1.6)

  • solspace / craft3-calendar(2.0.20)

如果您使用的是Solspace日历,则应考虑升级到v3。如果您正在使用Rias Contact表单扩展,则可以尝试通过运行a将更新的依赖项添加到composer.json文件中composer require nesbot/carbon它将修复警告,直到插件更新。                        

改善这个答案                            
       
1                        

谢谢你们两个 - 这是Freeform 3(已通知Solspace)                        

在此输入图像描述                        

改善这个答案                            
       
0                        

您安装的其中一个插件要么直接包含Carbon 1依赖项(或间接通过其中一个依赖项)。                        

无论做什么,最终应该更新为使用Carbon 2。                        

改善这个答案                            
       

来自  https://craftcms.stackexchange.com/questions/30714/carbon-1-is-deprecated-migrate-to-carbon-2            


普通分类: