65c1b5fb75
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Application;
|
|
|
|
final readonly class ProjectPaths
|
|
{
|
|
private function __construct(
|
|
public string $project,
|
|
) {
|
|
}
|
|
|
|
public static function resolve(string $start): self
|
|
{
|
|
$directory = is_file($start) ? dirname($start) : $start;
|
|
$directory = rtrim($directory, DIRECTORY_SEPARATOR);
|
|
|
|
while ($directory !== dirname($directory)) {
|
|
if (is_file($directory . '/composer.json')) {
|
|
return new self(realpath($directory) ?: $directory);
|
|
}
|
|
$directory = dirname($directory);
|
|
}
|
|
|
|
throw new \InvalidArgumentException("Unable to resolve project root from {$start}.");
|
|
}
|
|
|
|
public function configuration(): string
|
|
{
|
|
return $this->project . '/config';
|
|
}
|
|
|
|
public function modules(): string
|
|
{
|
|
return $this->project . '/modules';
|
|
}
|
|
|
|
public function cache(string $environment): string
|
|
{
|
|
return $this->project . '/var/cache/' . $environment;
|
|
}
|
|
|
|
public function logs(): string
|
|
{
|
|
return $this->project . '/var/log';
|
|
}
|
|
|
|
public function runtime(): string
|
|
{
|
|
return $this->project . '/var';
|
|
}
|
|
}
|