首页 > 编程语言 >thinkphp: thinkphp6升级到thinkphp8(8.0.1)

thinkphp: thinkphp6升级到thinkphp8(8.0.1)

时间:2023-07-27 14:35:28浏览次数:40  
标签:thinkphp8 PHP 8.0 psr composer topthink thinkphp php think

一,官方文档:

https://doc.thinkphp.cn/v8_0/setup.html

二,查看当前的php版本是否满足升级条件:

1,文档中的环境要求

2,查看本地的php版本:

liuhongdi@lhdpc:~$ /usr/local/soft/php8/bin/php --version
PHP 8.1.1 (cli) (built: Dec 20 2021 16:12:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

当前版本是 8.1.1 ,显然符合条件

3,查看当前项止的thinkphp版本:

liuhongdi@lhdpc:/data/php/tpapibase$ php think version
v6.1.0

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/07/20/thinkphp-thinkphp6-sheng-ji-dao-thinkphp8-8-1/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]

三,升级thinkphp

1,升级原项目到可用的最新版本:

liuhongdi@lhdpc:/data/php/tpapibase$ composer update topthink/framework
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading topthink/framework (v6.1.1 => v6.1.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downloading topthink/framework (v6.1.4)
  - Upgrading topthink/framework (v6.1.1 => v6.1.4): Extracting archive
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
File /data/php/tpapibase/config/trace.php exist!
Succeed!
4 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
liuhongdi@lhdpc:/data/php/tpapibase$ php think version
v6.1.4

可以看到升级完成后版本是v6.1.4

2,修改composer.json

"require": {
        "php": ">=8.0.0",
        "topthink/framework": "^8.0",
        "topthink/think-orm": "^3.0",
        "topthink/think-filesystem": "^2.0"
    },
    "require-dev": {
        "symfony/var-dumper": ">=4.2",
        "topthink/think-trace":"^1.0"
    },

对require需要用到的库的版本调整,我的配置版本号如上,

“topthink/think-filesystem”: “^2.0”,   这一行是我手动添加上的,

说明:这些版本号是从哪里来的?

用下面的命令新创建一个thinkphp8项目,从composer.json中就看到了

liuhongdi@lhdpc:/data/php$ composer create-project topthink/think tp8

3,删除composer.lock

liuhongdi@lhdpc:/data/php/tpapibase$ rm composer.lock

4,升级前查看当前各库的版本:

liuhongdi@lhdpc:/data/php/tpapibase$ composer show
firebase/php-jwt          v6.3.1  A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
psr/container             1.1.2   Common Container Interface (PHP FIG PSR-11)
psr/http-message          1.0.1   Common interface for HTTP messages
psr/log                   1.1.4   Common interface for logging libraries
psr/simple-cache          1.0.1   Common interfaces for simple caching
symfony/polyfill-mbstring v1.27.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72    v1.27.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php80    v1.27.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/var-dumper        v4.4.47 Provides mechanisms for walking through any arbitrary PHP variable
topthink/framework        v6.1.4  The ThinkPHP Framework.
topthink/think-helper     v3.1.6  The ThinkPHP6 Helper Package
topthink/think-orm        v2.0.56 think orm
topthink/think-trace      v1.5    thinkphp debug trace

5,升级:

liuhongdi@lhdpc:/data/php/tpapibase$ composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Lock file operations: 14 installs, 0 updates, 0 removals
  - Locking firebase/php-jwt (v6.8.0)
  - Locking league/flysystem (2.5.0)
  - Locking league/mime-type-detection (1.11.0)
  - Locking psr/container (2.0.2)
  - Locking psr/http-message (1.1)
  - Locking psr/log (3.0.0)
  - Locking psr/simple-cache (3.0.0)
  - Locking symfony/polyfill-mbstring (v1.27.0)
  - Locking symfony/var-dumper (v6.3.0)
  - Locking topthink/framework (v8.0.1)
  - Locking topthink/think-filesystem (v2.0.2)
  - Locking topthink/think-helper (v3.1.6)
  - Locking topthink/think-orm (v3.0.11)
  - Locking topthink/think-trace (v1.6)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 6 updates, 2 removals
  - Downloading league/mime-type-detection (1.11.0)
  - Downloading psr/container (2.0.2)
  - Downloading symfony/var-dumper (v6.3.0)
  - Downloading psr/simple-cache (3.0.0)
  - Downloading psr/log (3.0.0)
  - Downloading topthink/think-orm (v3.0.11)
  - Downloading topthink/framework (v8.0.1)
  - Downloading league/flysystem (2.5.0)
  - Downloading topthink/think-filesystem (v2.0.2)
  - Removing symfony/polyfill-php80 (v1.27.0)
  - Removing symfony/polyfill-php72 (v1.27.0)
  - Installing league/mime-type-detection (1.11.0): Extracting archive
  - Upgrading psr/container (1.1.2 => 2.0.2): Extracting archive
  - Upgrading symfony/var-dumper (v4.4.47 => v6.3.0): Extracting archive
  - Upgrading psr/simple-cache (1.0.1 => 3.0.0): Extracting archive
  - Upgrading psr/log (1.1.4 => 3.0.0): Extracting archive
  - Upgrading topthink/think-orm (v2.0.61 => v3.0.11): Extracting archive
  - Upgrading topthink/framework (v6.1.4 => v8.0.1): Extracting archive
  - Installing league/flysystem (2.5.0): Extracting archive
  - Installing topthink/think-filesystem (v2.0.2): Extracting archive
2 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
File /data/php/tpapibase/config/trace.php exist!
Succeed!
4 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

6,查看升级后的版本:

liuhongdi@lhdpc:/data/php/tpapibase$ composer show
firebase/php-jwt           v6.8.0  A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
league/flysystem           2.5.0   File storage abstraction for PHP
league/mime-type-detection 1.11.0  Mime-type detection for Flysystem
psr/container              2.0.2   Common Container Interface (PHP FIG PSR-11)
psr/http-message           1.1     Common interface for HTTP messages
psr/log                    3.0.0   Common interface for logging libraries
psr/simple-cache           3.0.0   Common interfaces for simple caching
symfony/polyfill-mbstring  v1.27.0 Symfony polyfill for the Mbstring extension
symfony/var-dumper         v6.3.0  Provides mechanisms for walking through any arbitrary PHP variable
topthink/framework         v8.0.1  The ThinkPHP Framework.
topthink/think-filesystem  v2.0.2  The ThinkPHP6.1 Filesystem Package
topthink/think-helper      v3.1.6  The ThinkPHP6 Helper Package
topthink/think-orm         v3.0.11 the PHP Database&ORM Framework
topthink/think-trace       v1.6    thinkphp debug trace

7,用php命令查看版本:

liuhongdi@lhdpc:/data/php/tpapibase$ php think version
v8.0.0

标签:thinkphp8,PHP,8.0,psr,composer,topthink,thinkphp,php,think
From: https://www.cnblogs.com/architectforest/p/17584818.html

相关文章

  • Debian11 TAR包安装MySQL8.0
    MySQL8下载地址访问https://downloads.mysql.com/archives/community/版本选择8.0.32,操作系统选择Linux-Generic,操作系统版本选择Linux-Generic(glibc2.17)(x86,64-bit);选择CompressedTARArchive,MinimalInstall点击下载,或者使用下面的URL直接下载https://cdn.my......
  • mysql8.0 centos7 xtrabackup步骤
    mysql8.0centos7xtrabackup步骤wgethttps://downloads.percona.com/downloads/Percona-XtraBackup-8.0/Percona-XtraBackup-8.0.33-28/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.33-28.1.el7.x86_64.rpmyuminstallcmakegccgcc-c++libaiolibaio-develauto......
  • Ubuntu18.04离线安装cuda,docker和nvidia-docker
    近来接手一个项目,服务器没有外网,还缺少一堆基础工具,离线安装相关依赖十分头疼。在此两篇博客记录一下此次经历。各部件的依赖如下:Nvida-docker需要CUDA驱动,安装CUDA需要GCC编译库,安装GCC需要用到make工具(make非必须)有关GCC依赖与make工具安装,请看另一篇博客。目录1.离线安装......
  • Njs 0.8.0发布
    导读Njs0.8.0发布,分为nginx模块和核心进行介绍。nginx模块更改:删除了0.7.10版本中引入的FetchAPI中对禁止的头信息的特殊处理。更改:删除了http模块中自0.5.0以来废弃的r.requestBody()和r.responseBody()。更改:在http模块中过滤时,在r.internalRedirect()中抛出一......
  • 微信 8.0 来啦,炸裂!
    阅读本文大概需要2.3分钟。前两天微信公开课十年之约,相信不少人都看直播了,直播过程中,龙哥除了讲解了他一直坚持的产品理念之外,还透漏了一些微信新版本的功能,就在刚刚,微信8.0新版本来啦,话不多说,直接给大家简单解析下新版本有哪些炸裂的功能吧。1.先给大家来一波微信8.0的欢迎......
  • Qt mingw73_32 + MySql8.0 使用和对数据库操作 - 初窥篇1
    1、开发环境QtCreator4.8.2+Qt5.12.2+MySql8.0.332、设计背景现在已经有MySql8.0.33是64位的数据库,仅支持64位的程序,但是当前Qt程序编译环境是mingw73_3232位程序连接64位的数据库实例3、操作流程1)测试驱动代码+测试结果intmain(inta......
  • 如何在Windows中安装WinCC V8.0
    通常SIMATICWinCC的产品包装中包含三张光盘。以WinCCV8.0为例,分别是WinCCV8.0、SIMATICNETV18和additionalContent。其中,WinCCV8.0是基本的安装包,SIMATICNETV18提供了通讯所必须的驱动程序,AdditionalContent中提供了SQLSERVER的管理工具。安装时需要注......
  • Android 8.0 framework 授予安装未知来源应用权限(去掉未知来源弹窗)
    Android8.0framework授予安装未知来源应用权限(去掉未知来源弹窗)在Android8.0及更高版本中,系统默认禁止安装来自未知来源的应用程序。这是为了确保用户设备的安全性,避免恶意软件的安装。然而,在某些情况下,我们可能仍然需要安装这些未知来源的应用程序。本文将介绍如何通过修改......
  • Ubantu下安装mysql8.0密码重置
    ubantu下安装mysql8.0使用推荐的aptitude来安装,省心省力。sudoaptitudeinstallmysql-server无脑“Y“安装成功。sudomysql-uroot-p会让你输入密码,密码???什么密码,什么时候有密码了。这种方式安装的貌似没有给设置密码的机会。所以需要重新设置。首先编辑sudovim/etc......
  • Qt(5.8.0)-运行框升级版
    Qt编程实现简单的命令行窗口本文介绍如何使用Qt框架编写一个简单的命令行窗口应用程序。通过该程序,用户可以在窗口中输入命令,并通过点击按钮执行命令。首先,我们需要创建一个名为"Widget"的类,继承自QWidget,用于创建应用程序的主窗口。以下是widget.h头文件中的代码:#ifndefWIDGE......