-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreact.php
More file actions
73 lines (57 loc) · 1.91 KB
/
react.php
File metadata and controls
73 lines (57 loc) · 1.91 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env php
<?php
require 'vendor/autoload.php';
use App\Providers\EventServiceProvider;
use Dotenv\Dotenv;
use React\EventLoop\Loop;
use Symfony\Component\Console\Application;
$commandNamespace = 'App\\Console\\Commands\\';
$seedNamespace = 'Database\\Seeds\\';
$_ENV['ARGV'] = $argv;
/**
* Handles exception thrown in the application
* @param Throwable $exception
*/
function handleApplicationException(Throwable $exception): void
{
//Save error log
$filename = __DIR__ . '/storage/logs/error-' . date('d_m_Y-H_i_s') . '.log';
file_put_contents($filename, $exception);
//Display to console
echo("\n[*] Error: {$exception->getMessage()} => {$exception->getFile()} @ Line {$exception->getLine()}\n\t --> Log File: {$filename}\n");
}
//Handle all exceptions thrown
set_exception_handler('handleApplicationException');
//Load environment variables
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
//Instantiate console application
$app = new Application($_ENV['APP_NAME'], $_ENV['APP_VERSION']);
//Load helpers
require __DIR__ . '/src/Helpers/generalHelperFunctions.php';
require __DIR__ . '/src/Helpers/socketHelperFunctions.php';
require __DIR__ . '/src/Helpers/httpHelperFunctions.php';
//Load all commands
$dirIterator = new DirectoryIterator(app_path('Console/Commands'));
foreach ($dirIterator as $item) {
if ($item->isFile()) {
$className = $commandNamespace . substr($item->getFilename(), 0, -4);
$command = new $className;
$app->add($command);
}
}
//Load all seeders
$dirIterator = new DirectoryIterator(root_path('database/Seeds'));
foreach ($dirIterator as $item) {
if ($item->isFile()) {
$_ENV['seeds'][] = $seedNamespace . substr($item->getFilename(), 0, -4);
}
}
//Load event listeners
EventServiceProvider::init()->boot();
//Run console application
try {
$app->run();
} catch (Exception $e) {
handleApplicationException($e);
}