從 4.0.4 升級到 4.0.5

請參考與您的安裝方法對應的升級說明。

中斷的增強功能

Message::getHeader(s)

HTTP 層正朝向 PSR-7 相容性 邁進。為此,Message::getHeader()Message::getHeaders() 已被棄用,應分別改用 Message::header()Message::headers()。請注意,這也適用於所有延伸 Message 的類別:RequestResponse 及其子類別。

HTTP 層中其他相關的棄用事項

  • Message::isJSON():直接檢查「Content-Type」標頭

  • Request[Interface]::isValidIP():使用 Validation 類別搭配 valid_ip

  • Request[Interface]::getMethod()$upper 參數將被移除,請使用 strtoupper()

  • Request[Trait]::$ipAddress:此屬性將變為私有

  • Request::$proxyIPs:此屬性將被移除;請直接存取 config('App')->proxyIPs

  • Request::__construct():建構函式將不再接受 Config\App,且已變為可為 null,以協助轉換

  • Response[Interface]::getReason():請改用 getReasonPhrase()

  • Response[Interface]::getStatusCode():明確的 int 回傳類型將被移除(無需採取任何動作)

ResponseInterface

此介面旨在納入任何架構相容回應類別所需的函式。架構預期的許多函式都遺失了,現在已新增。如果您使用任何實作 ResponseInterface 的類別,它們將需要與更新的要求相容。這些函式如下

  • setLastModified($date)

  • setLink(PagerInterface $pager)

  • setJSON($body, bool $unencoded = false)

  • getJSON()

  • setXML($body)

  • getXML()

  • send()

  • sendHeaders()

  • sendBody()

  • setCookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = false, $httponly = false, $samesite = null)

  • hasCookie(string $name, string $value = null, string $prefix = ''): bool

  • getCookie(字串 $name = null, 字串 $prefix = '')

  • deleteCookie(字串 $name = '', 字串 $domain = '', 字串 $path = '/', 字串 $prefix = '')

  • getCookies()

  • redirect(字串 $uri, 字串 $method = 'auto', 整數 $code = null)

  • download(字串 $filename = '', $data = '', 布林 $setMime = false)

為了便於使用此介面,這些方法已從框架的 Response 移至 ResponseTrait,您可以使用,而 DownloadResponse 現在直接擴充 Response,以確保最大的相容性。

Config\Services

服務發現已更新,允許第三方服務(透過模組啟用時)優先於核心服務。更新 app/Config/Services.php,讓類別擴充 CodeIgniter\Config\BaseService,以允許適當地發現第三方服務。

專案檔案

專案空間(根目錄、應用程式、公開、可寫)中的許多檔案已更新。由於這些檔案位於系統範圍之外,因此在您未介入的情況下,這些檔案不會變更。有些第三方 CodeIgniter 模組可協助合併專案空間的變更:在 Packagist 上探索

注意

除了極少數修正錯誤的案例外,對專案空間檔案所做的變更不會中斷您的應用程式。在此處註明的變更在下一主要版本之前都是選用的,任何強制性的變更都會在上述各節中說明。

內容變更

下列檔案已收到重大變更(包括不建議使用或視覺調整),建議您將更新的版本與您的應用程式合併

  • app/Views/*

  • public/index.php

  • public/.htaccess

  • spark

  • phpunit.xml.dist

  • composer.json

所有變更

這是專案空間中已收到變更的所有檔案清單;許多變更將是簡單的註解或格式化,對執行時間沒有影響

  • LICENSE

  • README.md

  • app/Config/App.php

  • app/Config/Autoload.php

  • app/Config/Boot/development.php

  • app/Config/Boot/production.php

  • app/Config/Boot/testing.php

  • app/Config/Cache.php

  • app/Config/Constants.php

  • app/Config/ContentSecurityPolicy.php

  • app/Config/Database.php

  • app/Config/DocTypes.php

  • app/Config/Email.php

  • app/Config/Encryption.php

  • app/Config/Events.php

  • app/Config/Exceptions.php

  • app/Config/Filters.php

  • app/Config/ForeignCharacters.php

  • app/Config/Format.php

  • app/Config/Generators.php

  • app/Config/Honeypot.php

  • app/Config/Images.php

  • app/Config/Kint.php

  • app/Config/Logger.php

  • app/Config/Migrations.php

  • app/Config/Mimes.php

  • app/Config/Modules.php

  • app/Config/Pager.php

  • app/Config/Paths.php

  • app/Config/Routes.php

  • app/Config/Security.php

  • app/Config/Services.php

  • app/Config/Toolbar.php

  • app/Config/UserAgents.php

  • app/Config/Validation.php

  • app/Config/View.php

  • app/Controllers/BaseController.php

  • app/Controllers/Home.php

  • app/Views/errors/cli/error_404.php

  • app/Views/errors/cli/error_exception.php

  • app/Views/errors/html/debug.css

  • app/Views/errors/html/debug.js

  • app/Views/errors/html/error_exception.php

  • composer.json

  • env

  • license.txt

  • phpunit.xml.dist

  • public/.htaccess

  • public/index.php

  • spark