auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

5.0.0 stable release #222

Closed frederikbosch closed 2 months ago

frederikbosch commented 2 months ago

Lessions from PR #221

After many refactorings I finally got what the best way is to implement the class and annotations scanner. In #221 I have added a auradi binary with a scan command. You can run this as follows:

# scan, but if cache exits, it returns the cache
vendor/bin/auradi scan

# force a complete new scan of all classes and annotations
vendor/bin/auradi scan --force

# use cache, and update only specific file
vendor/bin/auradi scan -u app/src/Controller/OrderController.php

The scan command will scan all packages, root and dependency packages, for an extra key in their composer.json. The paths added in the classmap-paths key will be scanned.

"extra": {
  "aura/di": {
    "classmap-paths": ["app"]
  }
}

The result is a file vendor/aura.di.scan.json that contains information about all found classes and annotations. It can be used by the container by passing an extra config to the container builder.

ClassScannerConfig::newScanner('vendor/aura.di.scan.json')

What's left for the publication of 5.0.0?

What's ahead for Aura/Di 5.1.0:

# execute a scan and watch for automatic file changes
vendor/bin/auradi scan --watch

The --watch parameter will use a new extension I am about to publish on PECL. The extension uses native filesystem notifications to rescan only the updated files.