Skip to content

Commit

Permalink
Merge pull request #10 from spiral-packages/feature/cleanup
Browse files Browse the repository at this point in the history
Code clean up an fixed problem with including bootloaders from differ…
  • Loading branch information
butschster authored Sep 23, 2022
2 parents e54ae42 + ebe62c1 commit b1ceacb
Show file tree
Hide file tree
Showing 22 changed files with 204 additions and 273 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
push:
branches:
- master

name: phpunit

jobs:
phpunit:
uses: spiral/gh-actions/.github/workflows/phpunit.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2']
stability: >-
['prefer-stable']
15 changes: 15 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
push:
branches:
- master

name: static analysis

jobs:
psalm:
uses: spiral/gh-actions/.github/workflows/psalm.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
53 changes: 0 additions & 53 deletions .github/workflows/run-tests.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/static-analysis.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/update-changelog.yml

This file was deleted.

41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Discoverer for Spiral Framework

[![PHP](https://img.shields.io/packagist/php-v/spiral-packages/discoverer.svg?style=flat-square)](https://packagist.org/packages/spiral-packages/discoverer)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spiral-packages/discoverer.svg?style=flat-square)](https://packagist.org/packages/spiral-packages/discoverer)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/spiral-packages/discoverer/run-tests?label=tests)](https://github.com/spiral-packages/discoverer/actions?query=workflow%3Arun-tests+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/spiral-packages/discoverer.svg?style=flat-square)](https://packagist.org/packages/spiral-packages/discoverer)
[![PHP Version Require](https://poser.pugx.org/spiral-packages/discoverer/require/php)](https://packagist.org/packages/spiral-packages/discoverer)
[![Latest Stable Version](https://poser.pugx.org/spiral-packages/discoverer/v/stable)](https://packagist.org/packages/spiral-packages/discoverer)
[![phpunit](https://github.com/spiral-packages/discoverer/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral-packages/discoverer/actions)
[![psalm](https://github.com/spiral-packages/discoverer/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral-packages/discoverer/actions)
[![Total Downloads](https://poser.pugx.org/spiral-packages/discoverer/downloads)](https://packagist.org/spiral-packages/discoverer/phpunit)

## Requirements

Expand Down Expand Up @@ -36,7 +37,7 @@ kernel.
use Spiral\Discoverer\WithDiscovering;
use Spiral\Framework\Kernel;

class App extends Kernel
class App extends Kernel
{
use WithDiscovering;
}
Expand Down Expand Up @@ -75,14 +76,16 @@ $app = App::create([
]);

$app->discover(
// Bootloaders sources
new \Spiral\Discoverer\Bootloader\BootloadersDiscoverer(
new \Spiral\Discoverer\Bootloader\ComposerRegistry(),
new \Spiral\Discoverer\Bootloader\ArrayRegistry(...),
new \Spiral\Discoverer\Bootloader\ConfigRegistry()
new \Spiral\Discoverer\Bootloader\ConfigRegistry()
),


// Tokenizer directories
new \Spiral\Discoverer\Tokenizer\DirectoriesDiscoverer(
new \Spiral\Discoverer\Tokenizer\ComposerRegistry(),
new \Spiral\Discoverer\Tokenizer\ComposerRegistry(),
)
);

Expand Down Expand Up @@ -147,7 +150,7 @@ Will register bootloaders from the passed array
new \Spiral\Discoverer\Bootloader\ArrayRegistry([
// Application specific logs
Bootloader\LoggingBootloader::class,

// ...
]),
```
Expand Down Expand Up @@ -196,12 +199,12 @@ final class JsonRegistry implements BootloaderRegistryInterface
{
private array $bootloaders = [];
private array $ignorableBootloaders = [];

public function __construct(
private string $jsonPath
) {
}

public function init(Container $container): void
{
// json structure
Expand All @@ -212,10 +215,10 @@ final class JsonRegistry implements BootloaderRegistryInterface
// ],
// "ignored_bootloaders": []
//}

$files = $container->get(FilesInterface::class);
$data = \json_decode($files->read($this->jsonPath), true);

$this->bootloaders = $data['bootloaders'] ?? [];
$this->ignorableBootloaders = $data['ignored_bootloaders'] ?? [];
}
Expand Down Expand Up @@ -277,7 +280,7 @@ Will register directories from application `composer.json` and from other instal
```

```php
new \Spiral\Discoverer\Tokenizer\ComposerRegistry(),
new \Spiral\Discoverer\Tokenizer\ComposerRegistry(),
```

#### Custom Directory registry
Expand All @@ -293,12 +296,12 @@ use Spiral\Files\FilesInterface;
final class JsonRegistry implements DirectoryRegistryInterface
{
private array $directories = [];

public function __construct(
private string $jsonPath
) {
}

public function init(Container $container): void
{
// json structure
Expand All @@ -308,12 +311,12 @@ final class JsonRegistry implements DirectoryRegistryInterface
// "src/Entities"
// ]
// }

$root = $container->get(\Spiral\Boot\DirectoriesInterface::class)->get('root');

$files = $container->get(FilesInterface::class);
$data = \json_decode($files->read($this->jsonPath), true);

$this->directories = \array_map(function (string $dir) use($root) {
return $root . $dir;
}, $data['directories'] ?? []);
Expand Down
Loading

0 comments on commit b1ceacb

Please sign in to comment.