1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-05 04:37:43 +02:00

feat(core): Added ability to override default constants

This commit is contained in:
Awilum
2022-06-24 22:02:44 +03:00
parent 17c494bfc1
commit da223475e0
4 changed files with 57 additions and 24 deletions

View File

@@ -15,22 +15,16 @@
namespace Flextype;
/**
* Define the Flextype start time in current unix timestamp (microseconds).
*/
define('START_TIME', microtime(true));
/**
* Define the PATH to the root directory (without trailing slash).
*/
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
/**
* Define the project name.
*/
define('PROJECT_NAME', 'project');
/**
* Define the PATH (without trailing slash).
*/
define('PATH_PROJECT', ROOT_DIR . '/' . PROJECT_NAME);
define('PATH_TMP', ROOT_DIR . '/var/tmp');
/**
* Ensure vendor libraries exist
*/

View File

@@ -21,22 +21,16 @@ use function is_file;
use function sprintf;
use function str_replace;
/**
* Define the Flextype start time in current unix timestamp (microseconds).
*/
define('START_TIME', microtime(true));
/**
* Define the PATH to the root directory (without trailing slash).
*/
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
/**
* Define the project name.
*/
define('PROJECT_NAME', 'project');
/**
* Define the PATH (without trailing slash).
*/
define('PATH_PROJECT', ROOT_DIR . '/' . PROJECT_NAME);
define('PATH_TMP', ROOT_DIR . '/var/tmp');
/**
* Ensure vendor libraries exist
*/

45
src/flextype/defines.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
* and with the full functionality of a traditional CMS!
*
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
*
* Licensed under The MIT License.
*
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*/
namespace Flextype;
if (! defined('FLEXTYPE_MINIMUM_PHP')) {
/**
* Define the Flextype Application minimum supported PHP version.
*/
define('FLEXTYPE_MINIMUM_PHP', '7.4.0');
}
if (! defined('PROJECT_NAME')) {
/**
* Define the project name.
*/
define('PROJECT_NAME', 'project');
}
if (! defined('PATH_PROJECT')) {
/**
* Define the project path (without trailing slash).
*/
define('PATH_PROJECT', ROOT_DIR . '/' . PROJECT_NAME);
}
if (! defined('PATH_TMP')) {
/**
* Define the project tmp path (without trailing slash).
*/
define('PATH_TMP', ROOT_DIR . '/var/tmp');
}

View File

@@ -84,8 +84,8 @@ use function version_compare;
use const DIRECTORY_SEPARATOR;
use const PHP_VERSION;
// Define the Flextype Application minimum supported PHP version.
define('FLEXTYPE_MINIMUM_PHP', '7.4.0');
// Get defines.
require_once ROOT_DIR . '/src/flextype/defines.php';
// 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 <strong>PHP %s</strong> to run.', $ver, $req));