-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.php
More file actions
41 lines (39 loc) · 1.73 KB
/
app.php
File metadata and controls
41 lines (39 loc) · 1.73 KB
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
34
35
36
37
38
39
40
41
<?php
/**
* Studio application loader
*
* This is the only resource that needs to be called.
*
* PHP version 8.3+
*
* @package capile/studio
* @author Tecnodesign <ti@tecnodz.com>
* @license GNU General Public License v3.0
* @link https://tecnodz.com
*/
if((isset($_SERVER['STUDIO_AUTOLOAD']) && file_exists($a=$_SERVER['STUDIO_AUTOLOAD'])) || file_exists($a=__DIR__.'/vendor/autoload.php')) require $a;
unset($a);
use Studio as S;
$env = S::env();
if(isset($_SERVER['STUDIO_CONFIG']) && $_SERVER['STUDIO_CONFIG'] && ($configFile=S::glob($_SERVER['STUDIO_CONFIG']))) {
if(!isset($configFile[1])) $configFile = array_shift($configFile);
} else if(!file_exists($configFile=S_PROJECT_ROOT.'/'.basename(S_PROJECT_ROOT).'.yml') &&
!file_exists($configFile=S_APP_ROOT.'/'.basename(S_APP_ROOT).'.yml')) {
$configFile = __DIR__.'/app.yml';
}
if(isset($_SERVER['STUDIO_TAG']) && $_SERVER['STUDIO_TAG']) {
$appMemoryNamespace = $_SERVER['STUDIO_TAG'];
} else if(file_exists(S_APP_ROOT.'/.appkey')) {
$appMemoryNamespace = S::slug(file_get_contents(S_APP_ROOT.'/.appkey'));
} else if(is_string($configFile)) {
$appMemoryNamespace = S::slug(basename($configFile, '.yml'));
} else {
$appMemoryNamespace = 'app';
}
S::app($configFile, $appMemoryNamespace, $env)->run();
if(S::$perfmon) {
$t = (isset($_SERVER['REQUEST_TIME_FLOAT'])) ?$_SERVER['REQUEST_TIME_FLOAT'] :S_TIME;
$s = date('Y-m-d H:i:s', floor($t)).substr(fmod($t,1), 1, 5)."\t".$appMemoryNamespace."\t".S::bytes(memory_get_peak_usage(true))."\t".S::number(microtime(true)-$t, 5)."s\t".S::requestUri();
if(isset(S::$variables['metrics'])) $s .= "\t".S::serialize(S::$variables['metrics'], 'json');
error_log($s."\n", 3, S::getApp()->app['log-dir'].'/perfmon.log');
}