Skip to content

Commit 90b818a

Browse files
committed
Add readme
1 parent 2dd8bbc commit 90b818a

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
11
# PHP Stack Detector
22

3+
This library allows to easily detect the PHP stack (Wordpress, Laravel, Symfony…) and the version used, when parsing a directory.
4+
5+
Supported Stacks for now:
6+
7+
- Wordpress
8+
- Laravel
9+
- Symfony
10+
- Statamic
11+
- Craft CMS
12+
13+
## Install
14+
15+
```
16+
composer require einenlum/php-stack-detector
17+
```
18+
19+
## Usage
20+
21+
```php
22+
<?php
23+
24+
require_once __DIR__ . '/vendor/autoload.php';
25+
26+
use Einenlum\PhpStackDetector\Detector;
27+
use Einenlum\PhpStackDetector\StackType;
28+
29+
$detector = Detector::create();
30+
$stack = $detector->getStack('/path/to/a/symfony/directory');
31+
32+
$stack->type === StackType===SYMFONY;
33+
$stack->version; // 5.4
34+
35+
$stack = $detector->getStack('/path/to/an/unknown/symfony/version/directory');
36+
$stack->type === StackType===SYMFONY;
37+
$stack->version; // null
38+
39+
$stack = $detector->getStack('/path/to/an/unknown/stack/directory');
40+
$stack; // null
41+
```
42+
343
## Tests
444

545
```
6-
make test
46+
composer run test
747
```
48+
49+
## Contribute
50+
51+
Each stack has its own Detector implementing a [StackDetectorInterface](src/StackDetectorInterface.php).
52+
If the stack uses composer you can use the [PackageVersionProvider](src/Composer/PackageVersionProvider.php) class.
53+
54+
You can add your own StackDetector and then add it to the `create` method of the [Detector](src/Detector.php).
55+
56+
Any Pull Request welcome!

0 commit comments

Comments
 (0)