Skip to content

Commit

Permalink
Support optimize commands in Laravel 11.27.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Oct 15, 2024
1 parent b7be870 commit adb5d77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ In production, run `ddd:cache` during the deployment process to [optimize autolo
```bash
php artisan ddd:cache
```
Note: Since Laravel 11.27.1, `ddd:cache` will automatically be invoked during Laravel's `optimize` command, in which case you do not need to run `ddd:cache` separately if your production environment already runs `optimize`.

### Version Compatibility
Laravel | LaravelDDD | |
Expand Down Expand Up @@ -145,9 +146,9 @@ Output:
│ ├─ StoreInvoiceRequest.php
│ └─ UpdateInvoiceRequest.php
├─ src/Domain
└─ Invoicing
└─ Models
└─ Invoice.php
└─ Invoicing
└─ Models
└─ Invoice.php
```

### Nested Objects
Expand Down Expand Up @@ -287,6 +288,8 @@ You may disable autoloading by setting the respective autoload options to `false
## 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.

Note: Since Laravel 11.27.1, `ddd:cache` and `ddd:clear` will automatically be invoked when running Laravel's `optimize` and `optimize:clear` respectively. If this applies to you and you are already running `optimize` in production, you don't need to manually run `ddd:cache`.

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

## Configuration File
Expand Down
8 changes: 8 additions & 0 deletions src/LaravelDDDServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public function packageBooted()
$this->publishes([
$this->package->basePath('/../stubs') => resource_path("stubs/{$this->package->shortName()}"),
], "{$this->package->shortName()}-stubs");

if ($this->app->runningInConsole() && method_exists($this, 'optimizes')) {
$this->optimizes(
optimize: 'ddd:cache',
clear: 'ddd:clear',
key: 'ddd:cache',
);
}
}

public function packageRegistered()
Expand Down

0 comments on commit adb5d77

Please sign in to comment.