You can utilize the One Time Activities bundle for Laravel to run code that ought to just pursue once arrangement. With this bundle, you can make activity classes that can be executed consequently utilizing a gave Craftsman order. Like movements, they just get handled once and afterward at no point ever run in the future.
When you generate classes using this package's operations:make
command, they use anonymous classes extending the OneTimeOperation
class:
use TimoKoerber\LaravelOneTimeOperations\OneTimeOperation; return new class extends OneTimeOperation{ /** * Determine if the operation is being processed asyncronously. */ protected bool $async = true; /** * Process the operation. */ public function process(): void { // }};
Using this package, you could update specific data after deploying new code, seed data after a migration, or run any type of code that you only need to execute once in tandem with a deployment. This package also provides the ability to test operations (run them multiple times without flagging them).
If you'd like to learn more about this package, you can check out the source code and readme docs on GitHub
0 comments:
Post a Comment
Thanks