Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PHP Stack Detector
# Stack Detector

This library allows to easily detect the PHP stack (Wordpress, Laravel, Symfony…) and the version used, when parsing a directory or ar Github remote repository.

Expand Down Expand Up @@ -36,7 +36,7 @@ Detected package managers:
## Install

```
composer require einenlum/php-stack-detector
composer require fortrabbit/stack-detector
```

## Usage
Expand All @@ -46,10 +46,10 @@ composer require einenlum/php-stack-detector

require_once __DIR__ . '/vendor/autoload.php';

use Einenlum\PhpStackDetector\Detector;
use Einenlum\PhpStackDetector\Factory\FilesystemDetectorFactory;
use Einenlum\PhpStackDetector\Factory\GithubDetectorFactory;
use Einenlum\PhpStackDetector\Enum\StackType;
use fortrabbit\StackDetector\Detector;
use fortrabbit\StackDetector\Factory\FilesystemDetectorFactory;
use fortrabbit\StackDetector\Factory\GithubDetectorFactory;
use fortrabbit\StackDetector\Enum\StackType;

// Local usage

Expand Down Expand Up @@ -101,10 +101,10 @@ $client = new \Github\Client();
$client->authenticate('some_access_token', null, \Github\AuthMethod::ACCESS_TOKEN);
$detector = $factory->create($client);

$config = $detector->getFullConfiguration('einenlum/private-repo');
$config = $detector->getFullConfiguration('fortrabbit/private-repo');

// optionally: detect the stack on a specific branch
$config = $detector->getFullConfiguration('einenlum/private-repo:branch-name');
$config = $detector->getFullConfiguration('fortrabbit/private-repo:branch-name');
```

You can also use the CLI to test it.
Expand Down Expand Up @@ -136,7 +136,7 @@ Package Manager: npm
It is advised to use an access token for github parsing, to either access private repositories or avoid reaching Github API limit.

```
GITHUB_ACCESS_TOKEN=my_token php bin/detect-github.php 'einenlum/private-repo'
GITHUB_ACCESS_TOKEN=my_token php bin/detect-github.php 'fortrabbit/private-repo'
Detected stack: laravel
Version: 10.19.0

Expand All @@ -153,10 +153,10 @@ For Github:

```yaml
services:
Einenlum\PhpStackDetector\Factory\GithubDetectorFactory: ~
fortrabbit\StackDetector\Factory\GithubDetectorFactory: ~

Einenlum\PhpStackDetector\Detector:
factory: ['@Einenlum\PhpStackDetector\Factory\GithubDetectorFactory', 'create']
fortrabbit\StackDetector\Detector:
factory: ['@fortrabbit\StackDetector\Factory\GithubDetectorFactory', 'create']
arguments:
$client: '@Github\Client'
```
Expand All @@ -165,10 +165,10 @@ For local filesystem:

```yaml
services:
Einenlum\PhpStackDetector\Factory\FilesystemDetectorFactory: ~
fortrabbit\StackDetector\Factory\FilesystemDetectorFactory: ~

Einenlum\PhpStackDetector\Detector:
factory: ['@Einenlum\PhpStackDetector\Factory\FilesystemDetectorFactory', 'create']
fortrabbit\StackDetector\Detector:
factory: ['@fortrabbit\StackDetector\Factory\FilesystemDetectorFactory', 'create']
```

## Tests
Expand Down
2 changes: 1 addition & 1 deletion bin/detect-github.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__.'/../vendor/autoload.php';

use Einenlum\PhpStackDetector\Factory\GithubDetectorFactory;
use fortrabbit\StackDetector\Factory\GithubDetectorFactory;
use Github\AuthMethod;

$factory = new GithubDetectorFactory();
Expand Down
2 changes: 1 addition & 1 deletion bin/detect-local.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once __DIR__.'/../vendor/autoload.php';

use Einenlum\PhpStackDetector\Factory\FilesystemDetectorFactory;
use fortrabbit\StackDetector\Factory\FilesystemDetectorFactory;

$factory = new FilesystemDetectorFactory();
$detector = $factory->create();
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "einenlum/php-stack-detector",
"description": "A package to detect the PHP stack of a project",
"name": "fortrabbit/stack-detector",
"description": "A package to detect the PHP stack and node config of a project",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Einenlum\\PhpStackDetector\\": "lib/"
"fortrabbit\\StackDetector\\": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"Einenlum\\Tests\\PhpStackDetector\\": "tests/"
"fortrabbit\\Tests\\StackDetector\\": "tests/"
}
},
"authors": [
Expand Down
12 changes: 6 additions & 6 deletions lib/Composer/ComposerConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Composer;
namespace fortrabbit\StackDetector\Composer;

use Einenlum\PhpStackDetector\DTO\Composer\ComposerConfig;
use Einenlum\PhpStackDetector\DTO\Enum\ComposerConfigType;
use Einenlum\PhpStackDetector\DirectoryCrawler\AdapterInterface;
use Einenlum\PhpStackDetector\Exception\CacheMissException;
use Einenlum\PhpStackDetector\Exception\ResourceNotFoundException;
use fortrabbit\StackDetector\DTO\Composer\ComposerConfig;
use fortrabbit\StackDetector\DTO\Enum\ComposerConfigType;
use fortrabbit\StackDetector\DirectoryCrawler\AdapterInterface;
use fortrabbit\StackDetector\Exception\CacheMissException;
use fortrabbit\StackDetector\Exception\ResourceNotFoundException;

/**
* We use an array cache so that we don't make expensive calls to the adapter
Expand Down
6 changes: 3 additions & 3 deletions lib/Composer/PackageVersionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Composer;
namespace fortrabbit\StackDetector\Composer;

use Einenlum\PhpStackDetector\DTO\Composer\PackageVersion;
use Einenlum\PhpStackDetector\DTO\Enum\ComposerConfigType;
use fortrabbit\StackDetector\DTO\Composer\PackageVersion;
use fortrabbit\StackDetector\DTO\Enum\ComposerConfigType;

readonly class PackageVersionProvider
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DTO/Composer/ComposerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO\Composer;
namespace fortrabbit\StackDetector\DTO\Composer;

use Einenlum\PhpStackDetector\DTO\Enum\ComposerConfigType;
use fortrabbit\StackDetector\DTO\Enum\ComposerConfigType;

readonly class ComposerConfig
{
Expand Down
2 changes: 1 addition & 1 deletion lib/DTO/Composer/PackageVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO\Composer;
namespace fortrabbit\StackDetector\DTO\Composer;

use Einenlum\ComposerVersionParser\Parser;

Expand Down
12 changes: 6 additions & 6 deletions lib/DTO/DependencyTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

use Einenlum\PhpStackDetector\StackDetector\LunarDetector;
use Einenlum\PhpStackDetector\StackDetector\OctoberCMSDetector;
use Einenlum\PhpStackDetector\StackDetector\StatamicDetector;
use Einenlum\PhpStackDetector\StackDetector\TwillDetector;
use Einenlum\PhpStackDetector\StackDetector\WinterCMSDetector;
use fortrabbit\StackDetector\StackDetector\LunarDetector;
use fortrabbit\StackDetector\StackDetector\OctoberCMSDetector;
use fortrabbit\StackDetector\StackDetector\StatamicDetector;
use fortrabbit\StackDetector\StackDetector\TwillDetector;
use fortrabbit\StackDetector\StackDetector\WinterCMSDetector;

class DependencyTree
{
Expand Down
2 changes: 1 addition & 1 deletion lib/DTO/Enum/ComposerConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO\Enum;
namespace fortrabbit\StackDetector\DTO\Enum;

enum ComposerConfigType: string
{
Expand Down
2 changes: 1 addition & 1 deletion lib/DTO/FullConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

readonly class FullConfiguration
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DTO/NodeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

use Einenlum\PhpStackDetector\Enum\NodePackageManagerType;
use fortrabbit\StackDetector\Enum\NodePackageManagerType;

readonly class NodeConfiguration
{
Expand Down
2 changes: 1 addition & 1 deletion lib/DTO/PhpConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

readonly class PhpConfiguration
{
Expand Down
2 changes: 1 addition & 1 deletion lib/DTO/PhpVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

readonly class PhpVersion
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DTO/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DTO;
namespace fortrabbit\StackDetector\DTO;

use Einenlum\PhpStackDetector\Enum\StackType;
use fortrabbit\StackDetector\Enum\StackType;

readonly class Stack
{
Expand Down
10 changes: 5 additions & 5 deletions lib/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector;
namespace fortrabbit\StackDetector;

use Einenlum\PhpStackDetector\DTO\FullConfiguration;
use Einenlum\PhpStackDetector\DTO\NodeConfiguration;
use Einenlum\PhpStackDetector\DTO\PhpConfiguration;
use Einenlum\PhpStackDetector\DTO\Stack;
use fortrabbit\StackDetector\DTO\FullConfiguration;
use fortrabbit\StackDetector\DTO\NodeConfiguration;
use fortrabbit\StackDetector\DTO\PhpConfiguration;
use fortrabbit\StackDetector\DTO\Stack;

readonly class Detector
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DirectoryCrawler/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DirectoryCrawler;
namespace fortrabbit\StackDetector\DirectoryCrawler;

use Einenlum\PhpStackDetector\Exception\ResourceNotFoundException;
use fortrabbit\StackDetector\Exception\ResourceNotFoundException;

interface AdapterInterface
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DirectoryCrawler/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DirectoryCrawler;
namespace fortrabbit\StackDetector\DirectoryCrawler;

use Einenlum\PhpStackDetector\Exception\ResourceNotFoundException;
use fortrabbit\StackDetector\Exception\ResourceNotFoundException;

class FilesystemAdapter implements AdapterInterface
{
Expand Down
4 changes: 2 additions & 2 deletions lib/DirectoryCrawler/GithubAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\DirectoryCrawler;
namespace fortrabbit\StackDetector\DirectoryCrawler;

use Einenlum\PhpStackDetector\Exception\ResourceNotFoundException;
use fortrabbit\StackDetector\Exception\ResourceNotFoundException;
use Github\Client;
use Github\Exception\RuntimeException;

Expand Down
2 changes: 1 addition & 1 deletion lib/Enum/NodePackageManagerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Enum;
namespace fortrabbit\StackDetector\Enum;

enum NodePackageManagerType: string
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Enum/StackType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Enum;
namespace fortrabbit\StackDetector\Enum;

enum StackType: string
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/CacheMissException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Exception;
namespace fortrabbit\StackDetector\Exception;

class CacheMissException extends \RuntimeException
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Exception/ResourceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Exception;
namespace fortrabbit\StackDetector\Exception;

class ResourceNotFoundException extends \RuntimeException
{
Expand Down
16 changes: 8 additions & 8 deletions lib/Factory/FilesystemDetectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Factory;

use Einenlum\PhpStackDetector\Composer\ComposerConfigProvider;
use Einenlum\PhpStackDetector\Detector;
use Einenlum\PhpStackDetector\DirectoryCrawler\FilesystemAdapter;
use Einenlum\PhpStackDetector\Node\PackageJsonProvider;
use Einenlum\PhpStackDetector\NodeConfigurationDetector;
use Einenlum\PhpStackDetector\PhpConfigurationDetector;
namespace fortrabbit\StackDetector\Factory;

use fortrabbit\StackDetector\Composer\ComposerConfigProvider;
use fortrabbit\StackDetector\Detector;
use fortrabbit\StackDetector\DirectoryCrawler\FilesystemAdapter;
use fortrabbit\StackDetector\Node\PackageJsonProvider;
use fortrabbit\StackDetector\NodeConfigurationDetector;
use fortrabbit\StackDetector\PhpConfigurationDetector;

class FilesystemDetectorFactory
{
Expand Down
16 changes: 8 additions & 8 deletions lib/Factory/GithubDetectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Einenlum\PhpStackDetector\Factory;

use Einenlum\PhpStackDetector\Composer\ComposerConfigProvider;
use Einenlum\PhpStackDetector\Detector;
use Einenlum\PhpStackDetector\DirectoryCrawler\GithubAdapter;
use Einenlum\PhpStackDetector\Node\PackageJsonProvider;
use Einenlum\PhpStackDetector\NodeConfigurationDetector;
use Einenlum\PhpStackDetector\PhpConfigurationDetector;
namespace fortrabbit\StackDetector\Factory;

use fortrabbit\StackDetector\Composer\ComposerConfigProvider;
use fortrabbit\StackDetector\Detector;
use fortrabbit\StackDetector\DirectoryCrawler\GithubAdapter;
use fortrabbit\StackDetector\Node\PackageJsonProvider;
use fortrabbit\StackDetector\NodeConfigurationDetector;
use fortrabbit\StackDetector\PhpConfigurationDetector;
use Github\Client;

class GithubDetectorFactory
Expand Down
Loading
Loading