PHP

★ How Flare's GitHub integration works under the hood

[AdSense-A]

Last week, my colleague Ruben and I launched a major new feature at Flare: there's a new integration with GitHub that makes it possible to:

  • create a GitHub issue directly on a Flare error
  • associate a GitHub issue with a Flare error by mentioning a Flare URL in the GitHub issue
  • automatically resolve an error on Flare when you close the GitHub issue
  • automatically close a GitHub issue when you resolve an error in Flare

In this stream, Ruben and I will show you how you can use this integration and how it works under the hood.

(more…)

By , ago
PHP

Queuing up in meetings

Distributing speaking time can be tricky when meeting face to face, but it is usuallly worse in virtual meetings. Especially those spanning long distances. In my current team, I learned how queues in remote meetings Read more…

By , ago
PHP

★ Injecting extra data in the payload of queued jobs in Laravel

[AdSense-A]

I'm proud to announce yet another package by our team: spatie/laravel-interacts-with-payload. This one, which was inspired by a blog post by James Brooks, can inject data in all your jobs with just one line of code.

In this video, you'll see the package in action, I explain the internals and the tests. If you prefer reading, continue below the video.

How you can inject things into every job of your app

Imagine that you want to have the user who initiated the queued job available in every queued job. Also, assume that your app has tens or hundreds of jobs you don't want to update manually.

Using this package, this is how you would solve that. Just use AllJobs::add to add things to all jobs.

// typically in the boot method of a service provider

use Spatie<span class="hljs-title">InteractsWithPayload<span class="hljs-title">Facades<span class="hljs-title">AllJobs;

AllJobs::add('user', fn() => auth()->user());

To retrieve the user in your job, you can call getFromPayload, which is available through the InteractsWithPayload trait.

use Illuminate<span class="hljs-title">Contracts<span class="hljs-title">Queue<span class="hljs-title">ShouldQueue;
use Spatie<span class="hljs-title">InteractsWithPayload<span class="hljs-title">Concerns<span class="hljs-title">InteractsWithPayload;

class YourJob implements ShouldQueue { use InteractsWithPayload;

<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handle</span><span class="hljs-params">()</span>
</span>{
    <span class="hljs-comment">// instance of User model or `null`</span>
    $user = <span class="hljs-keyword">$this</span>-&gt;getFromPayload(<span class="hljs-string">'user'</span>);
}  

}

If you want to know how the internals of this package work, watch the video linked above or read the code in the repo on GitHub.

(more…)

By , ago