@@ -267,13 +267,19 @@ Start the Temporal dev server:
267267
268268# # Custom Workers
269269
270- As you can see, there are several predefined workers for HTTP, Jobs, gRPC, and Temporal in `'workers'` section of `config/roadrunner.php`.
271- You can replace them with your own implementations if needed or create your own workers for other plugins, for example,
272- for [Centrifugo](https://docs.roadrunner.dev/docs/plugins/centrifuge), [TCP](https://docs.roadrunner.dev/docs/plugins/tcp)
273- or any other plugin.
270+ The RoadRunner Laravel Bridge comes with several predefined workers for common plugins,
271+ but you can easily create your own custom workers for any RoadRunner plugin.
272+ This section explains how to create and register custom workers in your application.
273+
274+ # ## Understanding Workers
275+
276+ Workers are responsible for handling requests from the RoadRunner server and processing them in your Laravel application.
277+ The predefined workers are configured in the `config/roadrunner.php` file :
274278
275279` ` ` php
276280return [
281+ // ... other configuration options ...
282+
277283 'workers' => [
278284 Mode::MODE_HTTP => HttpWorker::class,
279285 Mode::MODE_JOBS => QueueWorker::class,
@@ -283,7 +289,10 @@ return [
283289];
284290` ` `
285291
286- To create your own custom workers start from implementing the `Spiral\RoadRunnerLaravel\WorkerInterface` :
292+ # ## Creating Custom Workers
293+
294+ To create a custom worker, you need to implement the `Spiral\RoadRunnerLaravel\WorkerInterface`.
295+ This interface has a single method, `start()`, which is called when the worker is started by the RoadRunner server :
287296
288297` ` ` php
289298namespace App\W orkers;
@@ -300,12 +309,21 @@ class CustomWorker implements WorkerInterface
300309}
301310` ` `
302311
303- Then register it in the `config/roadrunner.php` :
312+ # ## Registering Custom Workers
313+
314+ After creating your custom worker, you need to register it in the `config/roadrunner.php` file :
304315
305316` ` ` php
306317return [
318+ // ... other configuration options ...
319+
307320 'workers' => [
308- 'custom' => \A pp\W orkers\C ustomWorker::class,
321+ // Existing workers
322+ Mode::MODE_HTTP => HttpWorker::class,
323+ Mode::MODE_JOBS => QueueWorker::class,
324+
325+ // Your custom worker for a custom or built-in plugin
326+ 'custom_plugin' => \A pp\W orkers\C ustomWorker::class,
309327 ],
310328];
311329` ` `
0 commit comments