How can a bootstrap.php file be used to load necessary components in PHP applications?

In PHP applications, a bootstrap.php file can be used to load necessary components such as configuration settings, autoloading classes, initializing dependencies, and setting up error handling. By including all these essential components in a single bootstrap file, it helps to streamline the application initialization process and ensures that everything is set up correctly before the application starts running.

// bootstrap.php

// Load configuration settings
require_once 'config.php';

// Autoload classes
require_once 'vendor/autoload.php';

// Initialize dependencies
$database = new Database();
$logger = new Logger();

// Set up error handling
set_error_handler('customErrorHandler');
set_exception_handler('customExceptionHandler');
register_shutdown_function('customShutdownFunction');