Start op project

This commit is contained in:
Tim 2025-03-18 19:01:15 +01:00
commit 08d014713a
3 changed files with 50 additions and 0 deletions

41
bundle.php Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
function line(string $text): void
{
echo $text . PHP_EOL;
}
if (count($argv) < 2) {
line('Usage: bundle.php <file>');
exit(1);
}
$targetFile = $argv[1];
if (!file_exists($targetFile)) {
line('File not found: ' . $targetFile);
exit(1);
}
function getIncludes(string $file): array
{
$content = file_get_contents($file);
$files = [];
foreach (explode("\n", $content) as $line) {
if (str_starts_with($line, 'include')) {
$line = "include 'test.include.php';";
preg_match("/include\s+'([^']+)'/", $line, $matches);
$files[] = $matches[1];
}
}
return $files;
}
var_dump(getIncludes($targetFile));
function buildIncludeTree(string $file): array
{
$includes = getIncludes($file);
foreach ($includes as $include) {
}
}

3
test.include.php Normal file
View File

@ -0,0 +1,3 @@
<?php
echo 'test.include' . PHP_EOL;

6
test.php Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env php
<?php
include 'test.include.php';
echo 'test' . PHP_EOL;