1. Go to this page and download the library: Download einenlum/php-stack-detector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
einenlum / php-stack-detector example snippets
inenlum\PhpStackDetector\Detector;
use Einenlum\PhpStackDetector\Factory\FilesystemDetectorFactory;
use Einenlum\PhpStackDetector\Factory\GithubDetectorFactory;
use Einenlum\PhpStackDetector\StackType;
// Local usage
$factory = new FilesystemDetectorFactory();
$detector = $factory->create();
$stack = $detector->getStack('/path/to/a/symfony/directory');
$stack->type === StackType::SYMFONY;
$stack->version; // 5.4
$stack = $detector->getStack('/path/to/an/unknown/symfony/version/directory');
$stack->type === StackType::SYMFONY;
$stack->version; // null
$stack = $detector->getStack('/path/to/an/unknown/stack/directory');
$stack; // null
// For Github usage
$factory = new GithubDetectorFactory();
$detector = $factory->create();
$stack = $detector->getStack('symfony/demo');
$stack->type === StackType::SYMFONY;
$stack->version; // 6.3.0
// You can also pass an already authenticated Github Client
$client = new \Github\Client();
$client->authenticate('some_access_token', null, \Github\AuthMethod::ACCESS_TOKEN);
$detector = $factory->create();
$stack = $detector->getStack('einenlum/private-repo');
$stack->type === StackType::SYMFONY;
$stack->version; // 6.3.0