Skip to content

Commit

Permalink
Add tasks to cache a manifest of event listeners (#1893)
Browse files Browse the repository at this point in the history
* Add tasks to cache a manifest of event listeners

Laravel supports automatic discovery of events and listeners since
version 5.8.9. (https://laravel.com/docs/5.8/events#event-discovery)
As the documentation states, you want to cache the manifest of event
listeners in a production environment to prevent scanning the
directories on every request.

The new tasks are not added to the deploy task because automatic event
discovery is opt-in functionality in Laravel.

* Update CHANGELOG.md
  • Loading branch information
wgriffioen authored and antonmedv committed Aug 6, 2019
1 parent bb4d41c commit a6ff2eb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog


## master
[v6.4.6...master](https://github.com/deployphp/deployer/compare/v6.4.6...master)

### Added
- A task to cache the event listeners manifest in Laravel [#1893]


## v6.4.6
[v6.4.5...v6.4.6](https://github.com/deployphp/deployer/compare/v6.4.5...v6.4.6)

Expand Down Expand Up @@ -489,6 +496,7 @@
- Fixed remove of shared dir on first deploy


[#1893]: https://github.com/deployphp/deployer/pull/1893
[#1881]: https://github.com/deployphp/deployer/pull/1881
[#1876]: https://github.com/deployphp/deployer/pull/1876
[#1842]: https://github.com/deployphp/deployer/pull/1842
Expand Down
20 changes: 20 additions & 0 deletions recipe/laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@
}
});

desc('Execute artisan event:cache');
task('artisan:event:cache', function () {
$needsVersion = '5.8.9';
$currentVersion = get('laravel_version');

if (version_compare($currentVersion, $needsVersion, '>=')) {
run('{{bin/php}} {{release_path}}/artisan event:cache');
}
});

desc('Execute artisan event:clear');
task('artisan:event:clear', function () {
$needsVersion = '5.8.9';
$currentVersion = get('laravel_version');

if (version_compare($currentVersion, $needsVersion, '>=')) {
run('{{bin/php}} {{release_path}}/artisan event:clear');
}
});

desc('Execute artisan optimize');
task('artisan:optimize', function () {
$deprecatedVersion = 5.5;
Expand Down

0 comments on commit a6ff2eb

Please sign in to comment.