如何更新laravel小版本?

1. 运行环境

1). 当前使用的 Laravel 版本?

Laravel Framework 9.33.0

2). 当前使用的 php/php-fpm 版本?

PHP 8.1.2-1ubuntu2.9 (cli)

2. 问题描述?

我想将laravel9升级到最新版本(不是升级到laravel10,是9的最后一个版本),报错

$ composer require laravel/framework
Using version ^10.2 for laravel/framework
./composer.json has been updated
Running composer update laravel/framework
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework 10.x-dev requires dragonmantank/cron-expression ^3.3.2 -> found dragonmantank/cron-expression[dev-set-up-semaphore, dev-update-v3-php8, dev-master, dev-issue/35-fix-and-or-problem, dev-allow-phpstan-failures, v1.0.0, ..., v1.2.1, v2.0.0, ..., v2.3.1.x-dev, v3.0.0, ..., v3.3.1] but it does not match the constraint.
    - laravel/framework v10.2.0 requires doctrine/inflector ^2.0.5 -> found doctrine/inflector[2.0.x-dev, 2.1.x-dev] but the package is fixed to 2.0.4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires laravel/framework ^10.2 -> satisfiable by laravel/framework[v10.2.0, 10.x-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require laravel/framework:*" to figure out if any version is installable, or "composer require laravel/framework:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

找了composer中文网 ,参考了
1、larave小版本怎么升级喃?
2、如何更新 Laravel 小版本?
一度弄到网站都无法访问。。。
求各位大佬指点。
感激不尽

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
nff93
最佳答案

composer upgrade -w laravel/framework

1年前 评论
____Laravel (楼主) 1年前
nff93 (作者) 1年前
____Laravel (楼主) 1年前
____Laravel (楼主) 1年前
nff93 (作者) 1年前
讨论数量: 27
gongmeng

去packagist找到你想要的版本号,手动修改composer.json为指定版本号,然后更新好依赖即可 packagist.org/packages/laravel/fra...

1年前 评论
____Laravel (楼主) 1年前

不同的版本所需要的依赖,和依赖所依赖的版本会有一些差异和冲突,需要去官网文档里面的升级指南部分跟着一步步来,而不是这样粗暴的一条 require 就能解决的。

1年前 评论
____Laravel (楼主) 1年前
Rache1 (作者) 1年前
____Laravel (楼主) 1年前

你这个办法很简单,你新建一个文件夹(别去改原先的项目),单独拷贝这个composer.json并修改这个文件,先去除除laravel以外其他东西,然后你一个一个加(用 composer require命令。),最后全部搞定之后,整个替换vendor文件夹,搞定!

1年前 评论
____Laravel (楼主) 1年前
composer update laravel/framework
1年前 评论
____Laravel (楼主) 1年前
lddtime (作者) 1年前
nff93

composer upgrade -w laravel/framework

1年前 评论
____Laravel (楼主) 1年前
nff93 (作者) 1年前
____Laravel (楼主) 1年前
____Laravel (楼主) 1年前
nff93 (作者) 1年前

我觉得我找到原因了,我之前执行了:

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

用了ali的镜像,但是这个镜像就只更新到9.33.0
导致我无法更新。。。太坑了

谢谢各位!!!

更新镜像:

~/wwwroot/test$composer config -g repo.packagist composer https://packagist.phpcomposer.com
//然后
~/wwwroot/test$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Root composer.json requires guzzlehttp/guzzle ^7.2, found guzzlehttp/guzzle[7.5.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 2
    - Root composer.json requires laravel/framework ^9.19, found laravel/framework[v9.33.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 3
    - Root composer.json requires laravel/sanctum ^3.0, found laravel/sanctum[v3.2.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 4
    - Root composer.json requires laravel/tinker ^2.7, found laravel/tinker[v2.8.1] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 5
    - Root composer.json requires fakerphp/faker ^1.9.1, found fakerphp/faker[v1.21.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 6
    - Root composer.json requires laravel/pint ^1.0, found laravel/pint[v1.6.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 7
    - Root composer.json requires laravel/sail ^1.0.1, found laravel/sail[v1.21.1] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 8
    - Root composer.json requires mockery/mockery ^1.4.4, found mockery/mockery[1.5.1] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 9
    - Root composer.json requires nunomaduro/collision ^6.1, found nunomaduro/collision[v6.4.0] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 10
    - Root composer.json requires phpunit/phpunit ^9.5.10, found phpunit/phpunit[9.6.4] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
  Problem 11
    - Root composer.json requires spatie/laravel-ignition ^1.0, found spatie/laravel-ignition[1.6.4] in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.
1年前 评论
____Laravel (作者) (楼主) 1年前
____Laravel (作者) (楼主) 1年前
nff93 1年前
boolstone 1年前

各位大佬回复的更新方法都对 但他喵的是:镜像更新问题和网络问题 暂时不更新了,后面再说, 谢谢热心的大佬们,结贴

1年前 评论
设置腾讯云镜像源试试
composer config -g repos.packagist composer https://mirrors.tencent.com/composer/
1年前 评论
____Laravel (楼主) 1年前
____Laravel (楼主) 1年前

一样也是被阿里云坑了

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!