SlideShare a Scribd company logo
升級指南
搭配 PhpStorm、Qodana 及 TeamCity
范聖佑
PHP 也有 Day #64
2022/02/24
Photo by Craig Stevenson on Unsplash
⼤家好!
— {
"name": "shengyou/self-introduction",
"description": "Self intro for PHP meetup",
"authors": [
{
"name": "范聖佑 (Shengyou Fan)",
"company": "JetBrains",
"role": "Developer Advocate",
"email": "shengyou.fan@jetbrains.com",
"homepage": "https://kraftsman.tw"
}
],
"support": {
"facebook": "https://fb.me/shengyoufan",
"telegram": "@shengyou",
"line": "shengyoufan"
}
}
!
各位⼿上的 PHP 專案有哪些版本?
都還好嗎? (欸 "
• 升級 PHP 的必要與重要性
• PHP 版本發佈與廢棄時間表
• PHP 升級指南
• ⽤ PhpStorm 協助升級
• ⽤ Qodana 確保升級品質
• 其他社群⼯具
本⽇⼤綱
—
• 安全性
為什麼要升級 PHP 版本?
—
From Wikipedia (https://en.wikipedia.org/wiki/End-of-life_product)
• 安全性
• 效能提升
為什麼要升級 PHP 版本?
—
https://kinsta.com/blog/php-benchmarks/ https://www.php.net/releases/8.1/en.php
• 安全性
• 效能提升
• 使⽤新版語法
為什麼要升級 PHP 版本?
—
PHP 版本發佈與廢棄時間表
—
https://www.php.net/supported-versions.php
• 2022 年 11 ⽉所有 7 以下的 PHP 版本全部 EOL
• 2022 年 11 ⽉所有維護中的 PHP 版本都是 8 開頭
• 最新版 Laravel 9 最低要求 PHP 8
驅勢警訊
—
From Laravel News (https://laravel-news.com/laravel-9)
⛴
2022 年 12 ⽉正式邁⼊ PHP 8 的⼤時代!
意味著逃不掉的升級⼯作也跟著來了 $
• 最新發佈版本
• 最新語法介紹
• 升級指南
PHP 的更新資訊從哪看?
—
官⽅升級指南
—
• 8.0.x → 8.1.x
• 5.x → 7.x → 8.x
• 先指定 PHP 及 Composer
- composer.json
- PHP language level
- PHP Interpreter
- Composer Execution
開⼯之前…
—
• 本機安裝 (XAMPP、MAMP、⼿動安裝)
PhpStorm ⽀援的
Interpreter 安裝⽅式
—
• 本機安裝 (XAMPP、MAMP、⼿動安裝)
• Package Manager (Homebrew、Scoop、Apt)
PhpStorm ⽀援的
Interpreter 安裝⽅式
—
Homebrew 安裝多版本 PHP
—
$ brew install php
$ brew install php@8.1
$ brew install php@8.0
$ brew install php@7.4
# 極限狀況
$ brew tap shivammathur/php
$ brew install shivammathur/php/php@5.6
Scoop 安裝多版本 PHP
—
$ scoop bucket add php
$ scoop install php/php8.1
$ scoop install php/php8.0
$ scoop install php/php7.4
Apt 安裝多版本 PHP
—
# 增加 repository
$ apt install software-properties-common
$ add-apt-repository ppa:ondrej/php
$ apt update
# 安裝多版本 PHP
$ apt install php
$ apt install php8.0
$ apt install php7.4
# 指定使⽤的 PHP 版本
$ update-alternatives --config php
• 本機安裝 (XAMPP、MAMP、⼿動安裝)
• Package Manager (Homebrew、Scoop、Apt)
• Vagrant (Homestead)
PhpStorm ⽀援的
Interpreter 安裝⽅式
—
• 本機安裝 (XAMPP、MAMP、⼿動安裝)
• Package Manager (Homebrew、Scoop、Apt)
• Vagrant (Homestead)
• SSH (遠端機器)
PhpStorm ⽀援的
Interpreter 安裝⽅式
—
• 本機安裝 (XAMPP、MAMP、⼿動安裝)
• Package Manager (Homebrew、Scoop、Apt)
• Vagrant (Homestead)
• SSH (遠端機器)
• Docker (Docker、Docker Compose)
PhpStorm ⽀援的
Interpreter 安裝⽅式
—
使⽤ Docker
—
$ docker pull php
$ docker pull php8.1*
$ docker pull php8.0*
$ docker pull php7.4*
• `composer` executable
• composer.phar
• Remote Interpreter
PhpStorm ⽀援的
Composer 安裝⽅式
—
使⽤ Docker
—
$ docker pull composer
# 注意 Composer 内的 PHP 版本
composer:2.2.4 → PHP 8.1.1
composer:1.9.3 → PHP 7.4.11
composer:1.7.3 → PHP 7.3.8
composer:1.5.1 → PHP 7.1.9
composer:1.5.0 → PHP 7.1.8
PhpStorm 團隊包好的
Docker Image
—
# 依需求使⽤不同的 Image
phpstorm/php-73-cli-xdebug-27
phpstorm/php-73-apache-xdebug-27
• 使⽤ PhpStorm 的三⼤排版⼯具
- Reformat
- Rearrange
- Optimize Imports
• 使⽤ PhpStorm 的快速修正 (Quick Fix)
• 使⽤ PhpStorm 的重構⼯具 (Refactoring)
• 使⽤ PhpStorm 的程式碼掃描⼯具 (Code Inspection)
• 使⽤ Qodana 確保升級品質
% PhpStorm ⼯具箱
—
快速修正
—
⌥ + ↩
Alt + Enter
macOS
Windows
Ctrl + T
重構
—
^ + T
macOS
Windows
Qodana
—
A code quality monitoring platform that allows you to
evaluate the integrity of code. It brings into your CI/
CD pipelines all the smart features you love in the
JetBrains IDEs as well as project-level checks like clone
detection and license audit.
https://www.jetbrains.com/qodana/
• JVM (Java, Kotlin)
• PHP (EAP)
• Python (EAP)
• JavaScript (EAP)
• Clone Finder (Experimental)
• License Audit (Experimental)
Qodana 提供的 Linters
—
整合 TeamCity
—
# qodana.yaml 設定
script:
name: php-migration
parameters:
fromLevel: 5.6
toLevel: 8.1
• 使⽤ Rector ⾃動升級
• 使⽤ PHPCompatibility 檢查相容性
% 社群⼯具箱
—
使⽤ Rector ⾃動升級
—
# 安裝 Rector
$ composer require rector/rector --dev
# 設定 Rector
$ ./vendor/bin/rector init
# 執⾏ Rector
$ ./vendor/bin/rector process src
使⽤ PHPCompatibility
—
# composer.json 設定
"require-dev": {
"phpcompatibility/php-compatibility": "*"
},
"scripts": {
"post-install-cmd": "...",
"post-update-cmd" : "..."
}
# 執⾏指令
$ ./vendor/bin/phpcs . 
--standard=PHPCompatibility 
--runtime-set testVersion 8.1
• 為什麼要⾯對 PHP 的版本更新?
• 如何⾯對 PHP 的版本更新?
• 有哪些⼯具可以使⽤?
本⽇回顧
—
• PHP 8 語法介紹
• 升級指南
• PhpStorm 新版特⾊
• Qodana Playground
想了解更多?
—
更多 PHP 8.1 新功能介紹
—
社群整理的升級指南
—
PhpStorm 2021.3 新功能介紹
—
Qodana Playground
—
產品團隊實際掃描各開放原始碼專案
&
關注道場粉絲⾴及社團們
—
社團
• Laravel 台灣
• PHP 也有 Day
• PHP 台灣
週⼀⾄五每天⼀篇新聞分享!
—
Coding 職⼈塾
Kraftsman
Q&A
—
范聖佑 (Shengyou Fan)
shengyou.fan@jetbrains.com
!
歡迎提問交流

More Related Content

PDF
Angular & RXJS: examples and use cases
Fabio Biondi
 
PDF
[JCConf 2022] Compose for Desktop - 開發桌面軟體的新選擇
Shengyou Fan
 
PDF
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
Shengyou Fan
 
PDF
Intro To React Native
FITC
 
PDF
初探 Kotlin Multiplatform
Shengyou Fan
 
PPTX
Node.js Express
Eyal Vardi
 
PPTX
Discover Quarkus and GraalVM
Romain Schlick
 
Angular & RXJS: examples and use cases
Fabio Biondi
 
[JCConf 2022] Compose for Desktop - 開發桌面軟體的新選擇
Shengyou Fan
 
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
Shengyou Fan
 
Intro To React Native
FITC
 
初探 Kotlin Multiplatform
Shengyou Fan
 
Node.js Express
Eyal Vardi
 
Discover Quarkus and GraalVM
Romain Schlick
 

What's hot (20)

PDF
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
PDF
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
PDF
給你一個使用 Laravel 的理由
Shengyou Fan
 
PDF
Try Jetpack Compose
LutasLin
 
PPTX
Spring Boot
Jiayun Zhou
 
PDF
Spring Boot
HongSeong Jeon
 
PPTX
Angular Unit Testing
Shailendra Chauhan
 
PDF
PHP 語法基礎與物件導向
Shengyou Fan
 
PPTX
Introduction to Spring Boot
Purbarun Chakrabarti
 
PPTX
iOS Architecture
DanielSelvanD
 
PPTX
JS Event Loop
Saai Vignesh P
 
PDF
Intro to react native
ModusJesus
 
PDF
Continuous Integration/Deployment with Gitlab CI
David Hahn
 
PDF
Java 17
Mutlu Okuducu
 
PDF
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
PDF
Introduction to Spring WebFlux #jsug #sf_a1
Toshiaki Maki
 
PDF
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
PPTX
JVM++: The Graal VM
Martin Toshev
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PDF
Expressjs
Yauheni Nikanovich
 
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
給你一個使用 Laravel 的理由
Shengyou Fan
 
Try Jetpack Compose
LutasLin
 
Spring Boot
Jiayun Zhou
 
Spring Boot
HongSeong Jeon
 
Angular Unit Testing
Shailendra Chauhan
 
PHP 語法基礎與物件導向
Shengyou Fan
 
Introduction to Spring Boot
Purbarun Chakrabarti
 
iOS Architecture
DanielSelvanD
 
JS Event Loop
Saai Vignesh P
 
Intro to react native
ModusJesus
 
Continuous Integration/Deployment with Gitlab CI
David Hahn
 
Java 17
Mutlu Okuducu
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
Introduction to Spring WebFlux #jsug #sf_a1
Toshiaki Maki
 
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
JVM++: The Graal VM
Martin Toshev
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Ad

Similar to [PHP 也有 Day #64] PHP 升級指南 (20)

PDF
Composer 從入門到實戰
Shengyou Fan
 
PDF
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
Shengyou Fan
 
PDF
凌波微步:wagon + VS Code 的輕功哲學
Shengyou Fan
 
KEY
移动端Web开发性能优化实践
Mingel Zhang
 
PDF
OpenWebSchool - 02 - PHP Part I
Hung-yu Lin
 
PDF
Openshift by mtchang
Chang Mt
 
PDF
[COSCUP 2022] 讓黑畫面再次偉大 - 用 PHP 寫 CLI 工具
Shengyou Fan
 
PPTX
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
scott liao
 
PPTX
Docker 基礎介紹與實戰
Bo-Yi Wu
 
PDF
[Modern Web Conf 2015] 給 PHP 開發者的 Composer 錦囊
Shengyou Fan
 
PDF
Python 于 webgame 的应用
勇浩 赖
 
PDF
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
Wen-Tien Chang
 
PDF
NodeJS基礎教學&簡介
GO LL
 
PDF
Django step0
永昇 陳
 
PDF
Php可调试团队开发环境配置
wangkangluo1
 
PDF
Php可调试团队开发环境配置
xinqi yang
 
PDF
2012 php conf slide PIXNET 如何使用 php
ronnywang_tw
 
PDF
2011 PHP技术高峰论坛演讲 张宴
Cosey Lee
 
PDF
Phalcon the fastest php framework 阿土伯
Hash Lin
 
PDF
Phalcon phpconftw2012
Rack Lin
 
Composer 從入門到實戰
Shengyou Fan
 
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
Shengyou Fan
 
凌波微步:wagon + VS Code 的輕功哲學
Shengyou Fan
 
移动端Web开发性能优化实践
Mingel Zhang
 
OpenWebSchool - 02 - PHP Part I
Hung-yu Lin
 
Openshift by mtchang
Chang Mt
 
[COSCUP 2022] 讓黑畫面再次偉大 - 用 PHP 寫 CLI 工具
Shengyou Fan
 
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
scott liao
 
Docker 基礎介紹與實戰
Bo-Yi Wu
 
[Modern Web Conf 2015] 給 PHP 開發者的 Composer 錦囊
Shengyou Fan
 
Python 于 webgame 的应用
勇浩 赖
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
Wen-Tien Chang
 
NodeJS基礎教學&簡介
GO LL
 
Django step0
永昇 陳
 
Php可调试团队开发环境配置
wangkangluo1
 
Php可调试团队开发环境配置
xinqi yang
 
2012 php conf slide PIXNET 如何使用 php
ronnywang_tw
 
2011 PHP技术高峰论坛演讲 张宴
Cosey Lee
 
Phalcon the fastest php framework 阿土伯
Hash Lin
 
Phalcon phpconftw2012
Rack Lin
 
Ad

More from Shengyou Fan (20)

PDF
[JCConf 2024] Kotlin/Wasm:為 Kotlin 多平台帶來更多可能性
Shengyou Fan
 
PDF
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
Shengyou Fan
 
PDF
[JCConf 2023] 從 Kotlin Multiplatform 到 Compose Multiplatform:在多平台間輕鬆共用業務邏輯與 U...
Shengyou Fan
 
PDF
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
Shengyou Fan
 
PDF
[WebConf Taiwan 2023] 一份 Zend Engine 外帶!透過 Micro 讓一次打包、多處運行變得可能
Shengyou Fan
 
PDF
How I make a podcast website using serverless technology in 2023
Shengyou Fan
 
PDF
[Effective Kotlin 讀書會] 第八章 Efficient collection processing 導讀
Shengyou Fan
 
PDF
Using the Exposed SQL Framework to Manage Your Database
Shengyou Fan
 
PDF
[COSCUP 2022] Kotlin Collection 遊樂園
Shengyou Fan
 
PDF
簡化 JVM 上雲 - 透過 Azure Spring Cloud 提升開發、發佈及服務監控效率
Shengyou Fan
 
PDF
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
Shengyou Fan
 
PDF
Composer 經典食譜
Shengyou Fan
 
PDF
老派浪漫:用 Kotlin 寫 Command Line 工具
Shengyou Fan
 
PDF
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
Shengyou Fan
 
PDF
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
Shengyou Fan
 
PDF
[Kotlin Serverless 工作坊] 單元 2 - 簡介 Kotlin Serverless
Shengyou Fan
 
PDF
[Kotlin Serverless 工作坊] 單元 1 - 開發環境建置
Shengyou Fan
 
PDF
用 Kotlin 打造讀書會小幫手
Shengyou Fan
 
PDF
Kotlin 讀書會第三梯次第一章
Shengyou Fan
 
PDF
用 OPENRNDR 將 Chatbot 訊息視覺化
Shengyou Fan
 
[JCConf 2024] Kotlin/Wasm:為 Kotlin 多平台帶來更多可能性
Shengyou Fan
 
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
Shengyou Fan
 
[JCConf 2023] 從 Kotlin Multiplatform 到 Compose Multiplatform:在多平台間輕鬆共用業務邏輯與 U...
Shengyou Fan
 
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
Shengyou Fan
 
[WebConf Taiwan 2023] 一份 Zend Engine 外帶!透過 Micro 讓一次打包、多處運行變得可能
Shengyou Fan
 
How I make a podcast website using serverless technology in 2023
Shengyou Fan
 
[Effective Kotlin 讀書會] 第八章 Efficient collection processing 導讀
Shengyou Fan
 
Using the Exposed SQL Framework to Manage Your Database
Shengyou Fan
 
[COSCUP 2022] Kotlin Collection 遊樂園
Shengyou Fan
 
簡化 JVM 上雲 - 透過 Azure Spring Cloud 提升開發、發佈及服務監控效率
Shengyou Fan
 
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
Shengyou Fan
 
Composer 經典食譜
Shengyou Fan
 
老派浪漫:用 Kotlin 寫 Command Line 工具
Shengyou Fan
 
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
Shengyou Fan
 
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
Shengyou Fan
 
[Kotlin Serverless 工作坊] 單元 2 - 簡介 Kotlin Serverless
Shengyou Fan
 
[Kotlin Serverless 工作坊] 單元 1 - 開發環境建置
Shengyou Fan
 
用 Kotlin 打造讀書會小幫手
Shengyou Fan
 
Kotlin 讀書會第三梯次第一章
Shengyou Fan
 
用 OPENRNDR 將 Chatbot 訊息視覺化
Shengyou Fan
 

[PHP 也有 Day #64] PHP 升級指南