I'm Confusing what is the advantage between commands and events however we can achieve our requirement by using commands what events can do then why use of events
Asked
Active
Viewed 124 times
1 Answers
0
Yes, in some way they are the same. I think (correct me if i'm wrong) it is just for separating code and creating cleaner applications.
For example console commands are more likely to be used in the 'console' by Artisan. Events however are used inside the application and fired when some sort of interaction takes place.
However when you want to call some script (command or event) you always have to trigger it manually.
Command: Artisan::call('email:send', $somedata);
Event: Event::fire(new SendEmailEvent($somedata));
I prefer to use events when something took place inside my application (like someone uploaded a file) and commands to fire scripts to maintain the application (like cron jobs etc).
Hope this helps you choosing :)

Thomas Van der Veen
- 3,136
- 2
- 21
- 36