Skip to content

Commit

Permalink
Update config and readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Apr 15, 2024
1 parent 5a73f0a commit 01501c7
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
64 changes: 52 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ When `ddd.autoload.factories` is enabled, the package will register a custom fac

If your application implements its own factory discovery using `Factory::guessFactoryNamesUsing()`, you should set `ddd.autoload.factories` to `false` to ensure it is not overridden.

### Ignoring Folders During Autoloading
To specify folders that should be skipped during autoloading discovery, add them to the `ddd.autoload_ignore` configuration option. By default, the `Tests` and `Migrations` folders are ignored.
```php
'autoload_ignore' => [
'Tests',
'Migrations',
],
```

Folders specified here are relative to the root of each domain. e.g., src/Domain/Invoicing/<folder-to-ignore>. If more advanced filtering is needed, a callback can be registered using the `DDD::filterAutoloadPathsUsing(callback $filter)` in your AppServiceProvider's boot method:
```php
use Lunarstorm\LaravelDDD\Facades\DDD;
use Symfony\Component\Finder\SplFileInfo;

DDD::filterAutoloadPathsUsing(function (SplFileInfo $file) {
if (basename($file->getRelativePathname()) === 'functions.php') {
return false;
}
});
```

### Disabling Autoloading
You may disable autoloading by setting the respective autoload options to `false` in the configuration file as needed, or by commenting out the autoload configuration entirely.
```php
Expand All @@ -221,11 +242,14 @@ You may disable autoloading by setting the respective autoload options to `false
// 'factories' => true,
// ],
```

<a name="autoloading-in-production"></a>

## Autoloading in Production
In production, you should cache the autoload manifests using the `ddd:cache` command as part of your application's deployment process. This will speed up the auto-discovery and registration of domain providers and commands. The `ddd:clear` command may be used to clear the cache if needed.

<a name="config-file"></a>

## Configuration File
This is the content of the published config file (`ddd.php`):

Expand Down Expand Up @@ -356,34 +380,50 @@ return [
*/
'autoload' => [
/**
* When enabled, any class in the domain layer extending
* `Illuminate\Support\ServiceProvider` will be
* auto-registered as a service provider
* When enabled, any class within the domain layer extending `Illuminate\Support\ServiceProvider`
* will be auto-registered as a service provider
*/
'providers' => true,

/**
* When enabled, any class in the domain layer extending
* `Illuminate\Console\Command` will be auto-registered
* as a command when running in console.
* When enabled, any class within the domain layer extending `Illuminate\Console\Command`
* will be auto-registered as a command when running in console.
*/
'commands' => true,

/**
* When enabled, a custom policy discovery callback will be
* registered to resolve policy names for domain models,
* or fallback to Laravel's default otherwise.
* When enabled, the package will register a custom policy discovery callback to resolve policy names
* for domain models, and fallback to Laravel's default for all other cases.
*/
'policies' => true,

/**
* When enabled, a custom policy discovery callback will be
* registered to resolve factory names for domain models,
* or fallback to Laravel's default otherwise.
* When enabled, the package will register a custom factory discovery callback to resolve factory names
* for domain models, and fallback to Laravel's default for all other cases.
*/
'factories' => true,
],

/*
|--------------------------------------------------------------------------
| Autoload Ignore Folders
|--------------------------------------------------------------------------
|
| Folders that should be skipped during autoloading discovery,
| relative to the root of each domain.
|
| e.g., src/Domain/Invoicing/<folder-to-ignore>
|
| If more advanced filtering is needed, a callback can be registered
| using the `DDD::filterAutoloadPathsUsing(callback $filter)` in
| the AppServiceProvider's boot method.
|
*/
'autoload_ignore' => [
'Tests',
'Migrations',
],

/*
|--------------------------------------------------------------------------
| Caching
Expand Down
20 changes: 20 additions & 0 deletions config/ddd.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@
'factories' => true,
],

/*
|--------------------------------------------------------------------------
| Autoload Ignore Folders
|--------------------------------------------------------------------------
|
| Folders that should be skipped during autoloading discovery,
| relative to the root of each domain.
|
| e.g., src/Domain/Invoicing/<folder-to-ignore>
|
| If more advanced filtering is needed, a callback can be registered
| using the `DDD::filterAutoloadPathsUsing(callback $filter)` in
| the AppServiceProvider's boot method.
|
*/
'autoload_ignore' => [
'Tests',
'Migrations',
],

/*
|--------------------------------------------------------------------------
| Caching
Expand Down

0 comments on commit 01501c7

Please sign in to comment.