Skip to content

Commit 1d6ee21

Browse files
committed
base bin file
Signed-off-by: Derek Smart <derek@grindaga.com>
1 parent 9fcd32f commit 1d6ee21

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

phpred

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* This file is the the main CLI for PHPRed.
5+
*
6+
* @copyright Derek Smart <derek@grindaga.com>
7+
* @author Derek Smart <derek@grindaga.com>
8+
* @license MIT
9+
*/
10+
11+
$minimunVersion = '7.0.0';
12+
if (version_compare($minimunVersion, PHP_VERSION, '>')) {
13+
echo 'PHPRed requires a minimum PHP version of 7.0' . PHP_EOL;
14+
die(1);
15+
}
16+
17+
$autoload = [
18+
__DIR__ . '/../src/autoload.php',
19+
__DIR__ . '/src/autoload.php',
20+
__DIR__ . '/../vendor/autoload.php',
21+
__DIR__ . '/vendor/autoload.php'
22+
];
23+
foreach ($autoload as $file) {
24+
if (file_exists($file)) {
25+
require $file;
26+
}
27+
}
28+
29+
$dotenv = new Dotenv\Dotenv(__DIR__);
30+
$dotenv->load();
31+
$dotenv->required([
32+
'db_name',
33+
'db_host',
34+
'db_username',
35+
'db_password',
36+
'db_port'
37+
])->notEmpty();
38+
39+
$mysqli = new \mysqli($_ENV['db_host'], $_ENV['db_username'], $_ENV['db_password'], $_ENV['db_name'], $_ENV['db_port']);
40+
if ($mysqli->connect_errno) {
41+
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
42+
}
43+
44+
$test = new \Test($mysqli);

0 commit comments

Comments
 (0)