<?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.3');
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 // Filtra erros de acordo com o nível de erro desejado
28 if ($errno === E_WARNING || $errno === E_NOTICE) {
29 \Core::log([$errno, $errstr, $errfile, $errline]);
30
31 return false; // Ignora esses tipos de erro
32 }
33
34 throw new Exception($errstr, $errno);
35 }
36);
37
38
39set_exception_handler(
40 function ($err) {
41 HandlerException($err);
42 }
43);
44
45//Função de carregamento automático das classes
46function _autoload($class)
47{
48 $folders = array(
49 array('Modules', 'Custom'),
50 array('Modules', 'Core'),
51 array('Modules', 'Classes'),
52 array('Controllers'),
53 array('Modules', 'Traits'),
54 array('vendor'),
55 array('Modules', 'Libraries'),
56 array('Modules', 'Interfaces'),
57 array('Models')
58 );
59
60 foreach ($folders as $folder) {
61 $file = MAIN_FOLDER . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $folder) . DIRECTORY_SEPARATOR . normalizeDirSeparator($class) . '.php';
62
63 if (file_exists($file)) {
64 //trace("Loading class '$class' from file '$file'", 'main', $class, TRACE_LOW);
65 require_once($file);
66
67 return;
68 }
69 }
70
71 trace("Class '$class' not found", 'main', $class, TRACE_ERROR);
72
73 throw new Exception("Class '$class' not found", 1);
74}
75
76//Auto registrar classes
77spl_autoload_register('_autoload');
78
79$composerAutoloadFile = MAIN_FOLDER . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
80
81if (file_exists($composerAutoloadFile)) {
82 require_once($composerAutoloadFile);
83} else {
84 Error('The composer autoload is not installed. Run composer install on console');
85}
86
87trace('System ready', 'main', MAIN_FOLDER, TRACE_LOW);
88You can see detailed error trace in the console.
render ()
/var/www/gazin.vc/index.php 20
parseMethod ()
/var/www/gazin.vc/Modules/Core/Navigation/Page.php 377
show ()
/var/www/gazin.vc/Modules/Core/Utils/Util.php 146
{closure} ()
/var/www/gazin.vc/Modules/Classes/SEO/Sitemap.php 159
You can see detailed error trace in the console.
main
System ready
'/var/www/gazin.vc'
web
Starting session
true
web
Starting web module
''
Culture
Auto discovering culture
NULL
Culture
Setting culture
'Brasil'
Navigation\Navigation
Setting Navigation default timezone
'America/Sao_Paulo'
Navigation\Navigation
Setting Navigation default language
false
web
User
'216.73.216.105'
Navigation\Navigation
Interpreting URI
'sitemap.xml'