Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch committed May 22, 2024
1 parent 05dbe9f commit 5b11802
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,23 @@ want to [modify the container using attributes](attributes.md#modify-the-contain
the passed namespaces will be compiled into blueprints, making sure all the required meta-data is there to create an
instance of the class.

This does require, however, to add a package to your dependencies.

```sh
composer require composer/class-map-generator
```

The following example demonstrates how to scan your project source files for annotations. The example compiles all
controllers, services and repository classes into a blueprints.

```php
$builder = new ContainerBuilder();
$config_classes = [
new \MyApp\Config1,
new \MyApp\Config2,
new ContainerConfigClassScanner(
[$rootDir . '/app/src'], // these directories should be scanned for classes and annotations
['MyApp\\'], // classes inside these namespaces should be compiled
['MyApp\\Controller\\', 'MyApp\\Service\\', 'MyApp\\Repository\\'], // classes inside these namespaces should be compiled
)
];

Expand Down
8 changes: 8 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ maximum performance, we would have to compile the container, serialize it and sa
Subsequent processes would only have to unserialize to have a compiled container. The `ContainerConfigClassScanner`
scans for classes and annotations inside your project.

This does require, however, to add a package to your dependencies.

```sh
composer require composer/class-map-generator
```

Creating a full-featured container could look as follows:

```php
use Aura\Di\ContainerBuilder;
use Aura\Di\ContainerConfigClassScanner;
Expand Down

0 comments on commit 5b11802

Please sign in to comment.