<?php
2
3/**
4 * Módulo padrão para todas as funções, responsável por carregar as classes e incluir funções globais
5 *
6 * @author Lucas/Postali
7 */
8
9define('REQUIRED_PHP_VERSION', '8.2');
10
11define('MAIN_FOLDER', __DIR__);
12
13/**
14 * Nomraliza os separadores de um nome de arquivo
15 * @param string $file Nome do arquivo
16 * @return string
17 */
18function normalizeDirSeparator($file)
19{
20 return preg_replace("/\\/|\\\\/", DIRECTORY_SEPARATOR, $file);
21}
22
23require_once('utils.php');
24
25set_error_handler(
26 function ($errno, $errstr, $errfile, $errline) {
27 throw new Exception($errstr, $errno);
28 }
29);
30
31set_exception_handler(
32 function ($err) {
33 HandlerException($err);
34 }
35);
36
37//Função de carregamento automático das classes
38function _autoload($class)
39{
40 $folders = array(
41 array('Modules', 'Custom'),
42 array('Modules', 'Core'),
43 array('Modules', 'Classes'),
44 array('Controllers'),
45 array('Modules', 'Traits'),
46 array('vendor'),
47 array('Modules', 'Libraries'),
48 array('Modules', 'Interfaces'),
49 array('Models'),
50 array('Tests'),
51 array('Scripts'),
52 );
53
54 foreach ($folders as $folder) {
55 $file = MAIN_FOLDER . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $folder) . DIRECTORY_SEPARATOR . normalizeDirSeparator($class) . '.php';
56
57 if (file_exists($file)) {
58 //trace("Loading class '$class' from file '$file'", 'main', $class, TRACE_LOW);
59 require_once($file);
60 return;
61 }
62 }
63
64 trace("Class '$class' not found", 'main', $class, TRACE_ERROR);
65 throw new Exception("Class '$class' not found", 1);
66}
67
68//Auto registrar classes
69spl_autoload_register('_autoload');
70
71$composerAutoloadFile = MAIN_FOLDER . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
72
73if (file_exists($composerAutoloadFile))
74 require_once($composerAutoloadFile);
75else
76 Error('The composer autoload is not installed. Run composer install on console');
77
78trace('System ready', 'main', MAIN_FOLDER, TRACE_LOW);
79
You can see detailed error trace in the console.
render ()
/home/stoneha/domains/dev.pipecore.stonehammer.com.br/public_html/index.php 19
parseMethod ()
/home/stoneha/domains/dev.pipecore.stonehammer.com.br/public_html/Modules/Core/Navigation/Page.php 377
show ()
/home/stoneha/domains/dev.pipecore.stonehammer.com.br/public_html/Modules/Core/Utils/Util.php 142
{closure} ()
/home/stoneha/domains/dev.pipecore.stonehammer.com.br/public_html/Modules/Classes/SEO/Sitemap.php 159
You can see detailed error trace in the console.
main
System ready
'/home/stoneha/domains/dev.pipecore.stonehammer.com.br/public_html'
web
Starting session
true
web
Starting web module
''
Navigation\Navigation
Setting Navigation default timezone
'America/Sao_Paulo'
Navigation\Navigation
Setting Navigation default language
false
web
User
'216.73.216.127'
Navigation\Navigation
Interpreting URI
'sitemap.xml'