/
include.constants.php
33 lines (30 loc) · 1.38 KB
/
include.constants.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
define('BENCHMARK_START', microtime(true));
define('BENCHMARK_MEMORY', memory_get_peak_usage());
// version of pusaka framework
define('PUSAKA_VERSION', '2.1.1');
// set root directory
define('ROOTDIR', strtr(__DIR__, ['\\' => '/']) . '/' );
// set application directory
define('APPDIR', ROOTDIR . 'app/');
// set components
define('COMPONENTS', ROOTDIR . 'app/web/components/components.php');
// set storage directory
define('STORAGEDIR', ROOTDIR . 'storage/');
// set media directory
define('MEDIADIR', ROOTDIR . 'storage/media/');
// set log directory
define('LOGDIR', ROOTDIR . 'storage/logs/');
// set cache directory
define('CACHEDIR', ROOTDIR . 'storage/caches/');
// non cli constants
//---------------------------------------------------------------
if( php_sapi_name() !== 'cli' ) :
// set webapps constant
define('USEPORT', $_SERVER['SERVER_PORT'] == 80 ? '': ':'.$_SERVER['SERVER_PORT'] );
define('DOMAIN', (($_SERVER['SERVER_NAME'] == '::1') ? 'localhost' : $_SERVER['SERVER_NAME']) );
define('BASEURL', (isset($_SERVER['HTTPS']) ? "https" : "http") . '://' . DOMAIN . USEPORT . (!file_exists('.htaccess') ? $_SERVER['SCRIPT_NAME'] . '/' : strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']) ) );
define('URL', preg_replace('/index\.php[\/]?/', '', BASEURL));
// set environtment
define('ENVIRONMENT', ((DOMAIN === 'localhost') ? 'DEVELOPMENT' : 'PRODUCTION'));
endif;