跳到主要內容

發表文章

目前顯示的是 6月, 2022的文章

CI 4.2.0 之後新增的 Auto Routing 設定

 一直以來都是利用  compose 來創建  CI4 的網站架構,在 CI4 更新到 4.2.0 版本之後,原本 function ***() 為作路徑的方式突然不能使用了,找了一下官網的說明之後,才發現有了新的 auto-routing 的設定。 Enable Auto Routing 開啟 auto-routing 的設定:修改 app/Config/Routes.php 設定 $routes->setAutoRoute(true) Enable Auto Routing (Improved) 基本上開啟上面的 auto-routing 的設定後,CI4 的路徑就會和以前一樣用 function name 來自動路由,但官網有建立還要再開啟 auto-routing(improved) 這個設定。 修改 app/Config/Features.php 開啟 auto-routing(improved)後,function 的名稱須要再加上 http method, 例如 getIndex()、postUpdate(),function 名稱配合 http method 才能正常執行,以增加網路安全,避免惡意的嚐試。

ci4 常用套件安裝

因為已經習慣用 codeigniter4(CI4)作網站開發,有部份常用套件的安裝流程紀錄起來,以後比較容易查詢。 Google APIs Client Library for PHP 安裝:composer require google/apiclient:^2.12.1 Github網址: https://github.com/googleapis/google-api-php-client 這個主要是用於 Google Oauth2 認證使用的。 PhpSpreadsheet 安裝:composer require phpoffice/phpspreadsheet Github網址: https://github.com/PHPOffice/PhpSpreadsheet 官網文件: https://phpspreadsheet.readthedocs.io/en/latest/ 處理Excel(或其他試算表檔案格式)的php 函式庫,用於匯入、匯出資料成試算表格式檔案。 Firebase 官網:h ttps://firebase.google.com/ 安裝:composer require tatter/firebase