-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.php
46 lines (39 loc) · 1.08 KB
/
boot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Support\Env;
use Utils\Migrations;
require 'vendor/autoload.php';
if (!function_exists('env')) {
/**
* Gets the value of an environment variable.
* @param string $key
* @param mixed $default
* @return mixed
*/
function env($key, $default = null): mixed
{
return Env::get($key, $default);
}
}
// read .env file
if (is_file(__DIR__ . DIRECTORY_SEPARATOR . '.env')) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
}
// initialize database
$database = env('DB_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . 'immopushr.sqlite');
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
'database' => $database,
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
## run migrations
require_once 'migrations.php';
Migrations::run();
## explicitly load providers
$files = glob(__DIR__ . DIRECTORY_SEPARATOR . 'provider' . DIRECTORY_SEPARATOR . '*.php');
foreach ($files as $file) {
require_once($file);
}