SuiteCRM-Core/index.php
Dillon-Brown 587a79613e Add API Platform Framework with Symfony/Flex
This implements the basic structure that will be used for the API and core application.
2021-03-30 19:21:30 +01:00

48 lines
1.4 KiB
PHP

<?php
use SuiteCRM\Core\src\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require __DIR__ . '/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies),
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
if (empty($_GET) && strpos($_SERVER['REQUEST_URI'], 'api') === false) {
if (!file_exists('public/index.html')) {
throw new RuntimeException('Please run bin/cli frontend:rebuild from terminal');
}
include __DIR__ . '/public/index.html';
die();
}
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
// Get the Application Path
define('BASE_PATH', __DIR__);
define('APP_PATH', __DIR__ . '/core/modules/');
define('LEGACY_PATH', __DIR__ . '/legacy/');
// Get the autoloader class
require BASE_PATH . '/vendor/autoload.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);