From bd1d938a60b71e1b8ad28ed08743dc448b32dd75 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 11 Jun 2019 21:18:18 +0300 Subject: [PATCH] Flextype Core: General fixes and refactoring #117 --- index.php | 57 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/index.php b/index.php index 2f9c147f..25a043b7 100755 --- a/index.php +++ b/index.php @@ -12,36 +12,57 @@ namespace Flextype; -// Define the application minimum supported PHP version. +/** + * Define the application minimum supported PHP version. + */ define('FLEXTYPE_MINIMUM_PHP', '7.1.3'); -// Define the path to the root directory (without trailing slash). +/** + * Define the PATH to the root directory (without trailing slash). + */ define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd())); -// Define the PATH (without trailing slash). -define('PATH', ['site' => ROOT_DIR . '/site', - 'plugins' => ROOT_DIR . '/site/plugins', - 'themes' => ROOT_DIR . '/site/themes', - 'entries' => ROOT_DIR . '/site/entries', - 'snippets' => ROOT_DIR . '/site/snippets', - 'menus' => ROOT_DIR . '/site/menus', - 'config' => [ +/** + * Define the PATH (without trailing slash). + */ +define('PATH', ['site' => ROOT_DIR . '/site', + 'plugins' => ROOT_DIR . '/site/plugins', + 'themes' => ROOT_DIR . '/site/themes', + 'entries' => ROOT_DIR . '/site/entries', + 'snippets' => ROOT_DIR . '/site/snippets', + 'fieldsets' => ROOT_DIR . '/site/fieldsets', + 'config' => [ 'default' => ROOT_DIR . '/flextype/config', 'site' => ROOT_DIR . '/site/config' ], - 'cache' => ROOT_DIR . '/site/cache']); + 'cache' => ROOT_DIR . '/site/cache']); -// Define the path to the logs directory (without trailing slash). -define('LOGS_PATH', PATH['site'] . '/logs'); - -// Check PHP Version +/** + * Check PHP Version + */ version_compare($ver = PHP_VERSION, $req = FLEXTYPE_MINIMUM_PHP, '<') and exit(sprintf('You are running PHP %s, but Flextype needs at least PHP %s to run.', $ver, $req)); -// Ensure vendor libraries exist +/** + * Ensure vendor libraries exist + */ !is_file($autoload = __DIR__ . '/vendor/autoload.php') and exit("Please run: composer install"); -// Register The Auto Loader +/** + * Register The Auto Loader + * + * Composer provides a convenient, automatically generated class loader for + * our application. We just need to utilize it! We'll simply require it + * into the script here so that we don't have to worry about manual + * loading any of our classes later on. It feels nice to relax. + * Register The Auto Loader + */ $loader = require_once $autoload; -// Get Flextype Bootstrap +/** + * Bootstraps the Flextype + * + * This bootstraps the Flextype and gets it ready for use, then it + * will load up this application so that we can run it and send + * the responses back to the browser and delight our users. + */ include 'flextype/bootstrap.php';