Skip to content

Commit c45f95e

Browse files
committed
Add a bin script
1 parent a5a6a2f commit c45f95e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ $stack = $detector->getStack('/path/to/an/unknown/stack/directory');
4040
$stack; // null
4141
```
4242

43+
You can also use the CLI to test it.
44+
45+
```
46+
php bin/detect.php ~/Prog/php/my_project/
47+
Detected stack: laravel
48+
Version: 10.19.0
49+
```
50+
4351
## Tests
4452

4553
```

bin/detect.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use Einenlum\PhpStackDetector\Detector;
6+
7+
$detector = Detector::create();
8+
9+
$directory = $argv[1] ?? null;
10+
if (null === $directory || !is_dir($directory)) {
11+
echo 'Please provide a directory to scan' . "\n";
12+
exit(1);
13+
}
14+
15+
$stack = $detector->getStack($directory);
16+
17+
if (null === $stack) {
18+
echo 'No stack detected' . "\n";
19+
exit(0);
20+
}
21+
22+
echo 'Detected stack: ' . $stack->type->value . "\n";
23+
echo 'Version: ' . ($stack->version ?: 'Unknown version') . "\n";

0 commit comments

Comments
 (0)