PHP code example of jobilla / laravel-app-events

1. Go to this page and download the library: Download jobilla/laravel-app-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/ */

    

jobilla / laravel-app-events example snippets


dispatch(new AppEvent('user.created', new User(['name' => $user->name])));

return [
    'enabled' => true,
    'project_id' => 'your-google-project',
    'topic' => 'app-events',
    'subscription' => 'login-handler'

    'mappings' => [
        'User' => App\Proto\User::class,
    ],
];

return [
    'enabled' => true,
    'project_id' => 'your-google-project',
    'topic' => 'app-events',
    'subscription' => 'user-registrator',

    'mappings' => [
        'User' => App\Proto\User::class,
    ],
    
    'handlers' => [
        'user.created' => App\Auth\RegisterUser::class,
    ],
];

class RegisterUser
{
    protected $registrator;

    public function __construct(Registrator $registrator)
    {
        $this->registrator = $registrator;
    }

    public function handle(User $user)
    {
        $this->registrator->register(
            $user->getName(),
            $user->getEmail(),
        );
    }
}