Application
in package
Application - Main Container (Singleton)
This class is the main entry point of the application. It initializes and provides access to all core services.
Pattern: Singleton (Service Locator)
This class implements the Singleton pattern to ensure a single instance manages all core services throughout the application lifecycle. It provides centralized access to:
- Session management
- HTTP request/response handling
- CSRF protection
- Authentication/authorization
Tags
Table of Contents
Properties
- $auth : AuthManager
- $csrf : CsrfProtection
- $instance : Application|null
- $request : Request
- $response : Response
- $session : SessionManager
Methods
- __wakeup() : void
- Prevent unserialization (Singleton pattern)
- auth() : AuthManager
- Get the authentication manager
- boot() : void
- Boot the application
- csrf() : CsrfProtection
- Get the CSRF protection service
- getInstance() : self
- Get the singleton instance of the application
- request() : Request
- Get the HTTP request instance
- response() : Response
- Get the HTTP response instance
- session() : SessionManager
- Get the session manager instance
- __clone() : void
- Prevent cloning (Singleton pattern)
- __construct() : mixed
- Private constructor (Singleton pattern)
Properties
$auth
private
AuthManager
$auth
$csrf
private
CsrfProtection
$csrf
$instance
private
static Application|null
$instance
= null
$request
private
Request
$request
$response
private
Response
$response
$session
private
SessionManager
$session
Methods
__wakeup()
Prevent unserialization (Singleton pattern)
public
__wakeup() : void
Tags
auth()
Get the authentication manager
public
auth() : AuthManager
Handles user login, logout, and permission checks.
Return values
AuthManager —The authentication manager
boot()
Boot the application
public
boot() : void
Starts the session and prepares the environment for request handling. Must be called once at application startup before processing requests.
csrf()
Get the CSRF protection service
public
csrf() : CsrfProtection
Provides token generation, validation, and HTML field generation.
Return values
CsrfProtection —The CSRF protection service
getInstance()
Get the singleton instance of the application
public
static getInstance() : self
Creates the instance on first call, then returns the same instance.
Return values
self —The unique Application instance
request()
Get the HTTP request instance
public
request() : Request
Provides access to GET/POST/SERVER data in an OOP manner.
Return values
Request —The current HTTP request with encapsulated superglobals
response()
Get the HTTP response instance
public
response() : Response
Provides methods for redirects, headers, and status codes.
Return values
Response —The response handler for HTTP output
session()
Get the session manager instance
public
session() : SessionManager
Provides access to session operations like get/set/flash messages.
Return values
SessionManager —The session manager for handling $_SESSION
__clone()
Prevent cloning (Singleton pattern)
private
__clone() : void
Tags
__construct()
Private constructor (Singleton pattern)
private
__construct() : mixed
Initializes all core services in dependency order:
- SessionManager - for session handling
- Request - HTTP request encapsulation
- Response - HTTP response management
- CsrfProtection - CSRF token handling (depends on SessionManager)
- AuthManager - Authentication/authorization (depends on SessionManager)