CodeIgniter 4.4の処理の流れ

(2024-04-16 追記) 「CodeIgniter 4.5の処理の流れ」 を書きました。

CodeIgniter 4.4の処理の流れをまとめました。

CodeIgniter 4.4 Process Flow

CodeIgniter 4.4 Process Flow

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()
        • load Composer autoloader
      • register()
    • autoload helpers
      • instantiate FileLocator
      • load URL helper
instantiate DotEnv
  • load .env file
define Environment
Services::codeigniter()
  • instantiate Config\App
  • instantiate CodeIgniter
initialize CodeIgniter
  • CodeIgniter::initialize()
    • load Environment bootstrap
    • Services::exceptions()
      • initialize()
        • set Exception/Error handler
    • check missing required PHP extensions
    • set default locale (Locale::setDefault())
    • set default timezone
    • initialize Kint
  • CodeIgniter::setContext()
CodeIgniter::run()
  • Services::createRequest()
    • Services::incomingrequest()
      • Services::uri()
        • Services::siteurifactory()
          • instantiate SiteURIFactory
        • SiteURIFactory::createFromGlobals()
          • detectRoutePath()
            • update superglobals
              • update $_SERVER
              • update $_GET
          • instantiate SiteURI
      • instantiate UserAgent
      • instantiate Request
        • IncomingRequest::__construct()
          • detectLocale()
            • if $negotiateLocale is true
              • get lang from content negotiation
              • setLocale()
                • set locale in Request
                • set default locale (Locale::setDefault())
  • instantiate Response
  • spoof request method
  • CodeIgniter::handleRequest()
    • force secure access
    • Event pre_system
    • check Page Cache
    • tryToRouteIt()
      • instantiate Route
      • instantiate Route
      • get Controller and method nam
      • get locale from rout
        • if route contains local
          • Request::setLocale(
            • set locale in Reques
            • set default locale (Locale::setDefault()
      • get Route Filters Info
    • instantiate 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
    • Event post_system
    • return Response object
  • send response

関連

Date: 2023/10/17

Tags: codeigniter, codeigniter4