Laravel听众优先事项

Let's say I have two listeners in Laravel like so:

Event::listen('eventOne', 'myListenerOne');
Event::listen('eventThree', 'myListenerThree');

I know by default the listener priority is set to 0. But what if I want to add an event between the two above?

Event::listen('eventTwo', 'myListenerTwo');

What would I set the priority to?

Laravel <= 5.3

Just add your listener with greater priority, say 1

Event::listen('eventTwo', 'myListenerTwo', 1);

Here is a small example to better understand event priorities

Event::listen(
     'test', function () {
             echo 'On test, first added but last executed', PHP_EOL;
         }, -1);


Event::listen(
     'test', function () {
             echo 'On test, added in the middle and executed in the middle', PHP_EOL;
         });


Event::listen(
     'test', function () {
             echo 'On test, last added but first executed', PHP_EOL;
         }, 1);

Event::fire('test');

P.S.:

You can always check yourself by looking into laravel sources, for example into Illuminate\Events\Dispatcher::sortListeners.

P.P.S.:

Event priorities has been removed in Laravel 5.4