This commit is contained in:
Juan Pablo Vial
2023-07-24 20:41:38 -04:00
parent 6ab24c8961
commit be33305cf1
612 changed files with 11436 additions and 107 deletions

View File

@ -0,0 +1,8 @@
<?php
include_once dirname(__DIR__) . '/vendor/autoload.php';
include_once 'errors.php';
include_once 'logs.php';
include_once 'dotenv.php';
include_once 'database.php';
include_once 'routes.php';
?>

View File

@ -0,0 +1,29 @@
<?php
$databases = config('databases');
load($databases['mysql']);
foreach ($databases as $name => $data) {
load($data, $name);
}
function load($data, $name = '') {
if (!isset($data['port'])) {
$port = 3306;
} else {
$port = $data['port'];
}
$dsn = 'mysql:host=' . $data['host'] . ';port=' . $port . ';dbname=' . $data['database'] . ';charset=utf8';
if ($name != '') {
ORM::configure($dsn, null, $name);
ORM::configure('username', $data['username'], $name);
ORM::configure('password', $data['password'], $name);
} else {
ORM::configure($dsn, null);
ORM::configure('username', $data['username']);
ORM::configure('password', $data['password']);
}
}
Model::$short_table_names = true;

View File

@ -0,0 +1,12 @@
<?php
use Dotenv\Dotenv;
$folder = dirname(__DIR__);
$files = new DirectoryIterator($folder);
foreach ($files as $file) {
if ($file->isDir() or $file->getExtension() != 'env') {
continue;
}
$env = Dotenv::createImmutable($file->getPath(), $file->getBasename());
$env->load();
}

View File

@ -0,0 +1,7 @@
<?php
/*if (config('app.debug')) {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
}*/
?>

View File

@ -0,0 +1,26 @@
<?php
use Monolog\{Handler,Processor,Formatter,Level};
function buildLogger() {
$logger = new Monolog\Logger('global', [
new Handler\FilterHandler(new Handler\RotatingFileHandler('/logs/php.log'),
Level::Debug,
Level::Notice
),
new Handler\FilterHandler(new Handler\RotatingFileHandler('/logs/error.log'),
Level::Warning,
Level::Critical
),
new Handler\FilterHandler(new Handler\NativeMailerHandler('jpvial@incoviba.cl', 'Incoviba Error', 'alert@incoviba.cl'),
Level::Alert
)
], [
new Processor\PsrLogMessageProcessor(),
new Processor\IntrospectionProcessor(),
new Processor\WebProcessor(),
new Processor\MemoryPeakUsageProcessor()
]);
return $logger;
}
$logger = buildLogger();
Monolog\ErrorHandler::register($logger);

View File

@ -0,0 +1,21 @@
<?php
use App\Contract\Route;
use Stringy\Stringy;
/*
* TODO: Language Changer
* Route::add('GET', 'change_language', function() {
\App\Contract\Session::set('App', 'lang', get('lang'));
header('Location: .');
});*/
$controllers = glob(config('locations.controllers') . '/*.php');
foreach ($controllers as $controller) {
$info = pathinfo($controller);
$name = $info['filename'];
$route = '' . Stringy::create($name)->underscored();
Route::add(['GET', 'POST'], $route, $name);
}
Route::add(['GET', 'POST'], 'buscar', 'Buscar');
?>