You can use the `event_dispatcher` service to trigger an event.

Use this code to trigger your event.

    \Drupal::service('event_dispatcher')->dispatch(MyModuleEvents::MY_EVENT, new MyModuleEventClass());

Of course you have to replace the names with your real names.

You can run the code using `drush php`.

You can read more about [subscribing and dispatching events here][1].


  [1]: https://www.drupal.org/docs/8/creating-custom-modules/subscribe-to-and-dispatch-events