init config as the class object, delegate db location logic to the database class, use realpath conversion for filename entities

This commit is contained in:
yggverse 2024-05-04 18:57:26 +03:00
parent a4a34c8ad1
commit 46bbf48f5f
3 changed files with 57 additions and 21 deletions

View file

@ -19,29 +19,15 @@ require_once __DIR__ .
if (empty($argv[1])) throw new \Exception;
// Init config
$config = json_decode(
file_get_contents(
str_starts_with(
$argv[1],
DIRECTORY_SEPARATOR
) ? $argv[1] // absolute
: __DIR__ . // relative
DIRECTORY_SEPARATOR . '..'.
DIRECTORY_SEPARATOR . 'config'.
DIRECTORY_SEPARATOR . $argv[1]
)
); if (!$config) throw new \Exception;
$config = new \Yggverse\Pulsar\Model\Config(
$argv[1]
);
$config = $config->get(); // registry only
// Init database
$database = new \Yggverse\Pulsar\Model\Database(
str_starts_with(
$config->database->location,
DIRECTORY_SEPARATOR
) ? $config->database->location
: __DIR__ .
DIRECTORY_SEPARATOR . '..'.
DIRECTORY_SEPARATOR . 'config'.
DIRECTORY_SEPARATOR . $config->database->location,
$config->database->location,
$config->database->username,
$config->database->password
);