Bootstrap
This commit is contained in:
6
bootstrap/autoload.php
Normal file
6
bootstrap/autoload.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
include_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
include_once 'errors.php';
|
||||||
|
include_once 'database.php';
|
||||||
|
include_once 'routes.php';
|
||||||
|
?>
|
30
bootstrap/database.php
Normal file
30
bootstrap/database.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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;
|
||||||
|
?>
|
7
bootstrap/errors.php
Normal file
7
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();
|
||||||
|
}
|
||||||
|
?>
|
21
bootstrap/routes.php
Normal file
21
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