什麼是 CodeIgniter
CodeIgniter 介紹
CodeIgniter 簡介
CodeIgniter 是 PHP 的一個框架,提供了許多函式庫給開發者用
並且有使用到 MVC 架構的方式,讓不管是開發或是維護程式更方便。
官網連結:首頁 | CodeIgniter台灣 輕量級 PHP網頁框架
為什麼要用 CodeIgniter
- 免費:CodeIgniter 是開源授權規範許的。
- 簡單:相比於其他 PHP 框架來說環境設定簡單些。
- 安全:內建了跨網站請求偽照 (CSRF) 與跨網站指令碼(XSS) 攻擊的防護。
- MVC:使用了 MVC 的方法,可以更好的使表現層、商業邏輯層分離。
MVC 簡介
MVC 是一種軟體開發的架構與邏輯。
MVC - Model、View、Controller 的縮寫,會分成 Model、View、Controller 是希望能把應用程式的運作歸納成不同的部門,讓每個部門各自負責不同的方面。
MVC 介紹
MVC 架構圖
- Controller
- 負責接收請求
- 協調 Model 與 View 回應結果
- Model
- View
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
CodeIgniter 畫面載入歷程
- Routing 路由器
- Filter 過濾器
- Services
- CodeIgniter 提供的服務(表單驗證,session 方法)
- Libraries 程式庫
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
為什麼要使用 MVC
- 開發方便:Model、View、Controller 分離更改 View 不會影響到 Model
- 維護容易:可以針對不同方向快速找到對應的檔案
- 易於團隊合作:有統一的架構規則,容易讀懂別人的程式碼
CodeIgniter 4
CodeIgniter 4 環境設定
php.ini 設定
- 至 Xampp 目錄下進入 php 資料夾找到 php.ini 檔
- 以 VSCode 開啟檔案
- 到約 900 行把 curl 以及 intl 起用
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
安裝 CodeIgniter
- 使用 CMD 到你要部屬 CodeIgniter 的資料夾
- 輸入 composer create-project codeigniter4/appstarter 專案名稱
- 等待下載完成就能看到 CodeIgnier 的資料夾
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
啟用開發伺服器
- 使用 VSCode 開啟新建的資料夾
- 開啟 Terminal
- 輸入 php spark serve start
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
接著打開網頁輸入 localhost:8080 就可以看到 CodeIgniter 的歡迎頁面
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
env 環境設置
- 把專案資料夾下的 env 複製一份重新貼上
- 把複製的 env 檔名重新命名為 .env
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
CodeIgniter 4 官網教學
英文官網教學文件
中文官網教學文件
參考資料
CodeIgnite 3
CodeIgniter 3 環境設定
CodeIgniter 3 下載
CodeIgniter 3 安裝檔
autoload.php 設定
- 到 application\config 下的 autoload.php
- 設定第 61 行 libraries 為 database, session, 其他 CodeIgniter 3 套件
- 設定第 95 行 helper 為 url
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
config.php 設定
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
database.php 設定
- 設定第 79 行 username 為 資料庫使用者名稱
- 設定第 80 行 psaaword 為 資料庫使用者密碼
- 設定第 81 行 database 為 資料庫名稱
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
CodeIgniter 3 官網教學
英文官網教學文件
中文官網教學文件