<?php

// errors are logged and shown as a plain error page with a reference code, never printed (App_ErrorGuard);
// registered first, it has no dependencies, so even a broken vendor/autoload.php ends in the error page
require_once __DIR__.'/../application/include/App/ErrorGuard.php';
App_ErrorGuard::register();

// MrpBridge (PHP 8.5 compatibility layer) + composer libraries; defines MRP_LIBPATH
require_once __DIR__.'/../vendor/autoload.php';

global $time, $memory;

$memory = memory_get_usage();
$time = microtime(true);

defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__).'/../application'));

// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

defined('SITE_ROOT') || define("SITE_ROOT", APPLICATION_PATH.'/..');

error_reporting(E_ALL);
define('USE_SESSION', true);

// Set our include path
$include_path = get_include_path().PATH_SEPARATOR;
$include_path .= MRP_LIBPATH.PATH_SEPARATOR;
$include_path .= APPLICATION_PATH.'/models'.PATH_SEPARATOR;
$include_path .= APPLICATION_PATH.'/modules'.PATH_SEPARATOR;
$include_path .= APPLICATION_PATH.'/include'.PATH_SEPARATOR;
$include_path .= APPLICATION_PATH.'/include/Controller'.PATH_SEPARATOR;
set_include_path($include_path);

define('PAYMENT_INI', APPLICATION_PATH.'/include/Controller/Mrp/Payment/payment.ini');

require_once '../application/bootstrap.php';
$app = new Mrp_Bootstrap('_'.APPLICATION_ENV);
$app->bootstrap()->run();
