PHP code example of acdphp / laravel-queued-events

1. Go to this page and download the library: Download acdphp/laravel-queued-events library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

acdphp / laravel-queued-events example snippets


   use Acdphp\QueuedEvents\Events\QueuedEvent;
  
   class UserCreatedEvent extends QueuedEvent
   {
       // Remove the Dispatchable trait
   
       public function __construct(public $object)
       {
       }
   }
   

   UserCreatedEvent::dispatch(['foo' => 'bar']);
   

   UserCreatedEvent::dispatch(['foo' => 'bar'])
       ->onConnection('your-fanout-queue-connection')
       ->onQueue('your-custom-queue');
   

    // Dispatches if $condition is true
    UserCreatedEvent::dispatchIf($condition, ['foo' => 'bar']);
    
    // Dispatches if $condition is false
    UserCreatedEvent::dispatchUnless($condition, ['foo' => 'bar']);
    

   UserCreatedEvent::internalDispatch(['foo' => 'bar']);
   
   UserCreatedEvent::internalDispatchIf(['foo' => 'bar']);
   
   UserCreatedEvent::internalDispatchUnless(['foo' => 'bar']);
   
shell
php artisan vendor:publish --tag=queued-events-config