freekmurze / freek-dev-comments

2 stars 0 forks source link

1371-refactoring-to-actions #28

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

Refactoring to actions - Freek Van der Herten's blog on PHP, Laravel and JavaScript

Freek Van der Herten is a developer and partner at Spatie.

https://freek.dev/1371-refactoring-to-actions

slk500 commented 4 years ago

"we've started using a concept called "actions". I would say it is a Command pattern?

amaelftah commented 4 years ago

i have a question . does actions can use other actions for example PublishPostAction can have SendTweetAction as constructor dependency ?

and if yes can you tell me how do you solve circular dependencies if happened ?

Thanks a lot

martinbean-contracting commented 4 years ago

I already do this, but with jobs, and particularly sync jobs. As @slk500 says, this is akin to commands (and not surprising given “queued jobs” in Laravel was borne out of the command bus that was introduced in 5.0 and gone by 5.1).

The make-up is the same: a job class has a single action, can be called in a controller or console command, and can be queued.