Lines 0.00% 0 / 15
Functions and Methods n/a 0 / 0
Classes and Traits n/a 0 / 0
Name Lines Functions and Methods CRAP Classes and Traits
1<?php
2declare(strict_types=1);
3
4
5use Lucent\Facades\FileSystem;
6
7/**
8 * Lucent framework bootstrap.
9 *
10 * Composer-only: no PHAR support. This file is autoloaded via the
11 * package's composer.json "autoload.files" entry, so requiring the
12 * package's autoloader is enough to boot the framework constants.
13 */
14
15// Package source directory (vendor/blueprintau/lucent/src in a consumer,
16// or this repo's src/ during development).
17define("ROOT", __DIR__ . DIRECTORY_SEPARATOR);
18
19// Project root: find the vendor directory from Composer's ClassLoader,
20// then go one level up. This works regardless of the vendor-dir name or
21// package path structure. Falls back to the repo root for development.
22$projectRoot = null;
23if (class_exists(\Composer\Autoload\ClassLoader::class)) {
24    $loaders = \Composer\Autoload\ClassLoader::getRegisteredLoaders();
25    $vendorDir = key($loaders);
26    if ($vendorDir !== null && is_dir($vendorDir)) {
27        // vendorDir is <project>/vendor — project root is its parent.
28        $projectRoot = dirname($vendorDir);
29    }
30}
31if ($projectRoot === null) {
32    // Fallback: running from the Lucent repo itself (src/ is 1 level below repo root).
33    $projectRoot = dirname(__DIR__, 1);
34}
35
36define("RUNNING_LOCATION", $projectRoot . DIRECTORY_SEPARATOR);
37
38// Version: read from Composer's InstalledVersions (always available
39// since this file is autoloaded via Composer's files entry).
40// getPrettyVersion() returns a meaningful string for dev installs too
41// (e.g. "dev-main"), unlike getVersion() which is null outside tagged
42// releases and would make VERSION fall back to 'unknown'.
43define("VERSION", \Composer\InstalledVersions::getPrettyVersion('blueprintau/lucent') ?: 'unknown');
44
45define("LUCENT", ROOT . "Lucent" . DIRECTORY_SEPARATOR);
46
47// Set file system root
48require_once LUCENT . "Facades" . DIRECTORY_SEPARATOR . "FileSystem.php";
49FileSystem::overrideRootPath(RUNNING_LOCATION);
50
51define("APP", FileSystem::rootPath() . DIRECTORY_SEPARATOR . "App" . DIRECTORY_SEPARATOR);
52
53