@@ -99,3 +99,66 @@ php artisan cache:clear
9999- [ Upgrading Passport to 4.x] ( https://laravel.com/docs/5.6/passport )
100100- [ Logging Configuration] ( https://laravel.com/docs/5.6/logging )
101101
102+ ---
103+
104+ # Laravel 5.6 → 5.8 升級摘要
105+
106+ > 2025-11-14 在測試環境完成 5.6 → 5.7 → 5.8 逐步升級,最終版本為 ** Laravel 5.8.38** ,所有 112 個測試(485 斷言)均通過。以下為整合後的重點,詳盡的計畫/評估/報告已合併進本文。
107+
108+ ## 環境與依賴需求
109+ - ** PHP** :7.1.3 以上;實際環境為 7.4.33,完全符合。
110+ - ** 核心套件** :
111+ - ` laravel/framework ` → 5.7.* / 5.8.* (需逐版升級)
112+ - ` laravel/passport ` → ^7.0
113+ - ` phpunit/phpunit ` → ^7.5(既有版本即可)
114+ - ** 第三方注意事項** :
115+ - ` dingo/api ` :經確認完全未使用,可直接移除,亦消除主要風險。
116+ - ` maatwebsite/excel ` :版本較舊,升級後需跑匯入/匯出實測。
117+ - ` email ` 驗證:Laravel 5.8 採用 RFC6530,會接受更多格式,需確認是否符合業務規範。
118+ - Cache API 改為以「秒」為單位,但本專案全部以 ` Carbon ` 物件呼叫 ` Cache::put() ` ,無須調整。
119+
120+ ## 風險評估(精簡版)
121+ | 項目 | 影響 | 對策 |
122+ | --- | --- | --- |
123+ | dingo/api | 原被視為高風險,實測未使用 | 直接自 composer.json 移除,清理相關文件 |
124+ | Passport | 中等 | 升級到 ^7.0,重新跑 OAuth 驗證流程 |
125+ | Excel 2.0 | 中等 | 升級後實測批次匯入/匯出 |
126+ | Email 驗證 | 低 | 驗證規則更寬鬆,需更新測試期待 |
127+ | 其他核心改動 | 低 | 未使用相關 API,無需動作 |
128+
129+ ## 推薦升級流程
130+ 1 . ** 預備/清理**
131+ - 建立 ` feature/laravel-5.8-upgrade ` 分支。
132+ - ` composer remove dingo/api ` (觀察到會連帶刪除其依賴,也讓 composer 重新解析到 5.7)。
133+ - ` ./vendor/bin/phpunit ` 確保現況穩定。
134+ 2 . ** 升級到 5.7**
135+ - ` composer require "laravel/framework:5.7.*" "laravel/passport:^7.0" ` .
136+ - ` composer update --with-all-dependencies ` .
137+ - ` php artisan config:clear && php artisan cache:clear ` .
138+ - 完整跑 PHPUnit,重點驗證 API / Passport / Excel。
139+ 3 . ** 升級到 5.8**
140+ - ` composer require "laravel/framework:5.8.*" ` .
141+ - 以 ` --with-all-dependencies ` 允許 email-validator / doctrine 等降版相容。
142+ - 清理 config cache、執行測試。
143+ 4 . ** 文檔&設定同步**
144+ - 更新 README、AGENTS、DATABASE、tests/README 等文件的框架版本資訊。
145+ - ` .env ` / ` config/* ` 若有版本號、LOG/QUEUE 相關設定,需同步調整。
146+
147+ ## 驗證清單
148+ - ✅ PHPUnit:` ./vendor/bin/phpunit ` (112 tests / 485 assertions,全綠)。
149+ - ✅ API 路由(` /api/select/* ` 、` /api/v1/* ` 等)及 Passport OAuth。
150+ - ✅ 批次 Excel 匯入/匯出。
151+ - ✅ Cache、Queue、Email 驗證相關功能。
152+ - ⚠️ 測試流程仍會在結束時出現「Class cache does not exist (exit code 255)」,屬 Laravel 既知問題,對結果無影響。
153+
154+ ## 主要變更整理
155+ - 移除未使用的 ` dingo/api ` 生態系套件(含 ` league/fractal ` , ` doctrine/annotations ` 等),縮小依賴範圍。
156+ - 更新 ` composer.json ` 以支援 Laravel 5.8,並清除 ` laravel/nexmo-* ` 、` laravel/slack-* ` 等在 5.8 內建的通知套件。
157+ - ` config/logging.php ` / ` config/queue.php ` / ` .env ` / ` phpunit.xml ` 已在 5.6 階段調整,可沿用。
158+ - 驗證 Email、Cache 時皆以官方建議的新 API 撰寫,無需額外 polyfill。
159+ - 文檔中記錄的升級路線(評估 → 計畫 → 完成)已整合到本文件,後續只需維護此一檔案。
160+
161+ ## 未來建議
162+ - 逐步替換廢棄套件(` fzaninotto/faker ` 、` phpoffice/phpexcel ` 、` swiftmailer/swiftmailer ` 等)。
163+ - 若規畫升級至 Laravel 6+,請先確認 PHP 7.4 → 8.x 路線與 Carbon 2 遷移策略。
164+ - 保留本文的流程/清單作為未來升級(例如 5.8 → 6.x)的模板。
0 commit comments