config
This commit is contained in:
8
app_old/bootstrap/autoload.php
Normal file
8
app_old/bootstrap/autoload.php
Normal 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';
|
||||
?>
|
29
app_old/bootstrap/database.php
Normal file
29
app_old/bootstrap/database.php
Normal 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;
|
12
app_old/bootstrap/dotenv.php
Normal file
12
app_old/bootstrap/dotenv.php
Normal 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();
|
||||
}
|
7
app_old/bootstrap/errors.php
Normal file
7
app_old/bootstrap/errors.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/*if (config('app.debug')) {
|
||||
$whoops = new \Whoops\Run;
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
$whoops->register();
|
||||
}*/
|
||||
?>
|
26
app_old/bootstrap/logs.php
Normal file
26
app_old/bootstrap/logs.php
Normal 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);
|
21
app_old/bootstrap/routes.php
Normal file
21
app_old/bootstrap/routes.php
Normal 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');
|
||||
?>
|
Reference in New Issue
Block a user