Laravel ShouldQueue How Does It Work : <p>I know how to use <code>ShouldQueue</code> my question is about why does it work the way it does.</p>

<p>I need to edit how my <code>new Job</code> is stored in the database, and therefore am digging through Laravel's internals.</p>

<p>The job I want to edit is launched from the following event listener:</p>

<pre><code>&lt;?php

namespace App\Listeners;

use App\Events\NewMail;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Jobs\SendEmail;
use Carbon\Carbon;
class NewMailListener implements ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  NewMail  $event
     * @return void
     */
    public function handle(NewMail $event)
    {
       $addressee = $event-&gt;user-&gt;name;
       $address = $event-&gt;user-&gt;email;
       $type = "NewMail";
       $job = (new SendEmail($type,$addressee,$address))-&gt;delay(Carbon::now()-&gt;addMinutes(10));
       dispatch($job);
    } 
}
</code></pre>

<p>What I don't understand is how the <code>ShouldQueue</code> magic works, because in the <a href="https://github.com/illuminate/contracts/blob/5.3/Queue/ShouldQueue.php" rel="noreferrer">source code</a> it appears to do nothing.</p>

<pre><code>&lt;?php

namespace Illuminate\Contracts\Queue;

interface ShouldQueue
{
    //
}
</code></pre>

<p>I understand it is a <a href="https://laravel.com/docs/5.5/contracts" rel="noreferrer">contract</a> but it's not defining anything... so what it is doing exactly? Is there some auto-loading happening from the namespace?</p>

<p>I wasn't sure what an interface was exactly, so I looked at this: <a href="http://php.net/manual/en/language.oop5.interfaces.php" rel="noreferrer">PHP Docs: Interfaces</a> and came away with the impression that even if it is for decoupling, and interface should be defining something, which I don't see in <code>ShouldQueue</code>.</p>

<p>The top comment on that PHP docs page says this:</p>

<blockquote>
  <p>An INTERFACE is provided so you can describe a set of functions and
  then hide the final implementation of those functions in an
  implementing class. This allows you to change the IMPLEMENTATION of
  those functions without changing how you use it.</p>
</blockquote>

<p>But where is this description of functions here?</p>

<p>PS - I know this interface/contract is being used to queue the event listener itself, not the job that I want to edit. But I'm hoping understanding how the queue interacts with the event listener will better inform me as to how it works for the jobs.</p>
