CodeIgniter 4.3の処理の流れ
(2024-04-16 追記) 「CodeIgniter 4.4の処理の流れ」 を書きました。
(2023-07-07 追記) 一部誤りがあったため、修正しました。
CodeIgniter 4.3の処理の流れをまとめました。
public/index.php
check PHP version
define constant FCPATH
instantiate Config\Paths
Config\Paths
- $systemDirectory
- $appDirectory
- $writableDirectory
- $testsDirectory
- $viewDirectory
load system/bootstrap.php
system/bootstrap.php
define constants for directory paths
- APPPATH
- ROOTPATH
- SYSTEMPATH
- WRITEPATH
- TESTPATH
load Config/Constants.php
- load Common.php
- load Autoloader
- load Services
Services::autoloader()
- instantiate Autoloader
- initialize()
- register()
autoload helpers
- URL helper
load Composer autoloader
instantiate DotEnv
- load .env file
Services::codeigniter()
- instantiate Config\App
- instantiate CodeIgniter
initialize CodeIgniter
CodeIgniter::initialize()
- detect Environment
- load Environment bootstrap
Services::exceptions()
Services::request()
Services::incomingrequest()
- Services::uri()
- instantiate UserAgent
instantiate Request
IncomingRequest::__construct()
detectURI()
update superglobals
- update $_SERVER
- update $_GET
update URI object
- set path in Request
detectLocale()
if $negotiateLocale is true
- get lang from content negotiation
setLocale()
- set locale in Request
- set default locale (Locale::setDefault())
Services::response()
- instantiate Response
instantiate Exception
Exception::initialize()
- set Exception/Error handler
check missing required PHP extensions
set default locale (Locale::setDefault())
- Config\App:$defaultLocale
set default timezone
- initialize Kint
CodeIgniter::setContext()
run CodeIgniter
CodeIgniter::run()
- Services::createRequest()
- force secure access
- spoof request method
- Event pre_system
- check Page Cache
CodeIgniter::handleRequest()
tryToRouteIt()
- instantiate Routes
- instantiate Router
- get Controller and method name
if route contains locale
Request::setLocale()
- set locale in Request
- set default locale (Locale::setDefault())
get Controller Filters
enable Controller Filters
- run before Filters
run Controller
- run Closure controller
or
- instantiate Controller
- Event post_controller_constructor
- run Controller method
gather output
run after Filters
- debug toolbar
send response
- Event post_system
- return Response object
関連
Date: 2022/10/31