Essential classes that power the Forge Engine framework. These core components handle application initialization, service discovery, class loading, and the overall application lifecycle.
The main application engine that bootstraps and runs the framework. The Engine class is responsible for initializing the application, loading modules, and handling the request-response cycle.
Initialize the engine with a dependency injection container.
$container = new Container();
$engine = new Engine($container);The dependency injection container instance.
Starts the application and handles the incoming request.
$engine = new Engine($container);
$engine->run();Returns the dependency injection container instance.
$container = $engine->getContainer();
$service = $container->get(MyService::class);Load and initialize all registered modules.
$engine->loadModules();Handles application initialization and service registration. The Bootstrap class is responsible for setting up essential services, loading configuration, and preparing the application for execution.
Bootstraps the application with essential services.
$container = new Container();
Bootstrap::boot($container);Load and register core services in the container.
Bootstrap::loadServices($container);Load application configuration from config files.
Bootstrap::loadConfiguration();Manages class loading and namespace registration. The Autoloader handles automatic loading of classes using PSR-4 autoloading standards and provides namespace mapping capabilities.
Register the autoloader with PHP's spl_autoload system.
Autoloader::register();Add a namespace to directory mapping.
Autoloader::addNamespace('App\\Controllers', 'app/controllers');
Autoloader::addNamespace('App\\Models', 'app/models');Attempt to load a specific class.
$loaded = Autoloader::loadClass('App\\Controllers\\UserController');Loads modules and their dependencies. The Loader class is responsible for discovering, loading, and initializing modules within the application.
Load a specific module from its path.
$loader = new Loader();
$loader->loadModule('modules/ForgeAuth');Get all currently loaded modules.
$modules = $loader->getLoadedModules();
foreach ($modules as $module) {
    echo $module->getName() . "\n";
}Discovers and registers services and event listeners. This class handles automatic service discovery, dependency injection setup, and event listener registration throughout the application.
Discover and register all available services.
$discover = new ServiceDiscoverSetup();
$discover->discoverServices();Register all event listeners found in the application.
$discover->registerEventListeners();The dependency injection container for managing services and dependencies. Provides service registration, resolution, and lifecycle management for the entire application.
Bind a service to the container.
$container->bind(UserService::class);
$container->bind(PaymentInterface::class, StripePayment::class);
$container->bind('config', fn() => new Config());Bind a singleton service to the container.
$container->singleton(CacheManager::class);
$container->singleton('logger', LoggerService::class);Resolve a service from the container.
$userService = $container->get(UserService::class);
$logger = $container->get('logger');Check if a service is bound in the container.
if ($container->has(UserService::class)) {
    $service = $container->get(UserService::class);
}Common patterns and examples for working with the Core Engine classes.
// Initialize autoloader
Autoloader::register();
Autoloader::addNamespace('App\\Controllers', 'app/controllers');
Autoloader::addNamespace('App\\Models', 'app/models');
// Create container and bootstrap
$container = new Container();
Bootstrap::boot($container);
// Create and run engine
$engine = new Engine($container);
$engine->run();// Register services in container
$container->singleton(DatabaseConnection::class, function() {
    return new DatabaseConnection([
        'host' => 'localhost',
        'database' => 'myapp',
        'username' => 'root',
        'password' => 'password'
    ]);
});
$container->bind(UserService::class, function($container) {
    return new UserService(
        $container->get(DatabaseConnection::class)
    );
});
// Use registered services
$userService = $container->get(UserService::class);$loader = new Loader();
// Load specific modules
$loader->loadModule('modules/ForgeAuth');
$loader->loadModule('modules/ForgeCache');
// Get loaded modules
$modules = $loader->getLoadedModules();
foreach ($modules as $module) {
    echo "Loaded: " . $module->getName() . "\n";
    echo "Version: " . $module->getVersion() . "\n";
}Recommended patterns and guidelines for working with the Core Engine.