Skip to content

Commit ba62e66

Browse files
committed
2025-08-18までの原文変更点反映。
1 parent 62d884c commit ba62e66

18 files changed

+628
-102
lines changed

original-en/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ Once the middleware has been attached to the route, you will automatically be pr
433433
<a name="a-note-on-fastcgi"></a>
434434
#### A Note on FastCGI
435435

436-
If you are using PHP FastCGI and Apache to serve your Laravel application, HTTP Basic authentication may not work correctly. To correct these problems, the following lines may be added to your application's `.htaccess` file:
436+
If you are using [PHP FastCGI](https://www.php.net/manual/en/install.fpm.php) and Apache to serve your Laravel application, HTTP Basic authentication may not work correctly. To correct these problems, the following lines may be added to your application's `.htaccess` file:
437437

438438
```apache
439439
RewriteCond %{HTTP:Authorization} ^(.+)$

original-en/cashier-paddle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Please refer to Paddle's documentation for more information on the [data contain
320320
321321
Offering product and subscription billing via your application can be intimidating. However, thanks to Cashier and [Paddle's Checkout Overlay](https://developer.paddle.com/concepts/sell/overlay-checkout), you can easily build modern, robust payment integrations.
322322

323-
To learn how to sell subscriptions using Cashier and Paddle's Checkout Overlay, let's consider the simple scenario of a subscription service with a basic monthly (`price_basic_monthly`) and yearly (`price_basic_yearly`) plan. These two prices could be grouped under a "Basic" product (`pro_basic`) in our Paddle dashboard. In addition, our subscription service might offer an Expert plan as `pro_expert`.
323+
To learn how to sell subscriptions using Cashier and Paddle's Checkout Overlay, let's consider the simple scenario of a subscription service with a basic monthly (`price_basic_monthly`) and yearly (`price_basic_yearly`) plan. These two prices could be grouped under a "Basic" product (`pro_basic`) in our Paddle dashboard. In addition, our subscription service might offer an "Expert" plan as `pro_expert`.
324324

325325
First, let's discover how a customer can subscribe to our services. Of course, you can imagine the customer might click a "subscribe" button for the Basic plan on our application's pricing page. This button will invoke a Paddle Checkout Overlay for their chosen plan. To get started, let's initiate a checkout session via the `checkout` method:
326326

original-en/eloquent-relationships.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ use App\Models\Book;
21872187

21882188
$books = Book::all();
21892189

2190-
if ($someCondition) {
2190+
if ($condition) {
21912191
$books->load('author', 'publisher');
21922192
}
21932193
```

original-en/events.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,19 @@ Event::defer(function () {
820820

821821
All events triggered within the closure will be dispatched after the closure is executed. This ensures that event listeners have access to all related records that were created during the deferred execution. If an exception occurs within the closure, the deferred events will not be dispatched.
822822

823+
To defer only specific events, pass an array of events as the second argument to the `defer` method:
824+
825+
```php
826+
use App\Models\User;
827+
use Illuminate\Support\Facades\Event;
828+
829+
Event::defer(function () {
830+
$user = User::create(['name' => 'Victoria Otwell']);
831+
832+
$user->posts()->create(['title' => 'My first post!']);
833+
}, ['eloquent.created: '.User::class]);
834+
```
835+
823836
<a name="event-subscribers"></a>
824837
## Event Subscribers
825838

original-en/horizon.md

Lines changed: 251 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
- [Introduction](#introduction)
44
- [Installation](#installation)
55
- [Configuration](#configuration)
6-
- [Balancing Strategies](#balancing-strategies)
76
- [Dashboard Authorization](#dashboard-authorization)
7+
- [Max Job Attempts](#max-job-attempts)
8+
- [Job Timeout](#job-timeout)
9+
- [Job Backoff](#job-backoff)
810
- [Silenced Jobs](#silenced-jobs)
11+
- [Balancing Strategies](#balancing-strategies)
12+
- [Auto Balancing](#auto-balancing)
13+
- [Simple Balancing](#simple-balancing)
14+
- [No Balancing](#no-balancing)
915
- [Upgrading Horizon](#upgrading-horizon)
1016
- [Running Horizon](#running-horizon)
1117
- [Deploying Horizon](#deploying-horizon)
@@ -123,41 +129,6 @@ While your application is in [maintenance mode](/docs/{{version}}/configuration#
123129

124130
Within Horizon's default configuration file, you will notice a `defaults` configuration option. This configuration option specifies the default values for your application's [supervisors](#supervisors). The supervisor's default configuration values will be merged into the supervisor's configuration for each environment, allowing you to avoid unnecessary repetition when defining your supervisors.
125131

126-
<a name="balancing-strategies"></a>
127-
### Balancing Strategies
128-
129-
Unlike Laravel's default queue system, Horizon allows you to choose from three worker balancing strategies: `simple`, `auto`, and `false`. The `simple` strategy splits incoming jobs evenly between worker processes:
130-
131-
'balance' => 'simple',
132-
133-
The `auto` strategy, which is the configuration file's default, adjusts the number of worker processes per queue based on the current workload of the queue. For example, if your `notifications` queue has 1,000 pending jobs while your `render` queue is empty, Horizon will allocate more workers to your `notifications` queue until the queue is empty.
134-
135-
When using the `auto` strategy, you may define the `minProcesses` and `maxProcesses` configuration options to control the minimum number of processes per queue and the maximum number of worker processes in total Horizon should scale up and down to:
136-
137-
```php
138-
'environments' => [
139-
'production' => [
140-
'supervisor-1' => [
141-
'connection' => 'redis',
142-
'queue' => ['default'],
143-
'balance' => 'auto',
144-
'autoScalingStrategy' => 'time',
145-
'minProcesses' => 1,
146-
'maxProcesses' => 10,
147-
'balanceMaxShift' => 1,
148-
'balanceCooldown' => 3,
149-
'tries' => 3,
150-
],
151-
],
152-
],
153-
```
154-
155-
The `autoScalingStrategy` configuration value determines if Horizon will assign more worker processes to queues based on the total amount of time it will take to clear the queue (`time` strategy) or by the total number of jobs on the queue (`size` strategy).
156-
157-
The `balanceMaxShift` and `balanceCooldown` configuration values determine how quickly Horizon will scale to meet worker demand. In the example above, a maximum of one new process will be created or destroyed every three seconds. You are free to tweak these values as necessary based on your application's needs.
158-
159-
When the `balance` option is set to `false`, the default Laravel behavior will be used, wherein queues are processed in the order they are listed in your configuration.
160-
161132
<a name="dashboard-authorization"></a>
162133
### Dashboard Authorization
163134

@@ -184,6 +155,82 @@ protected function gate(): void
184155

185156
Remember that Laravel automatically injects the authenticated user into the gate closure. If your application is providing Horizon security via another method, such as IP restrictions, then your Horizon users may not need to "login". Therefore, you will need to change `function (User $user)` closure signature above to `function (User $user = null)` in order to force Laravel to not require authentication.
186157

158+
<a name="max-job-attempts"></a>
159+
### Max Job Attempts
160+
161+
> [!NOTE]
162+
> Before refining these options, make sure you are familiar with Laravel's default [queue services](/docs/{{version}}/queues#max-job-attempts-and-timeout) and the concept of 'attempts'.
163+
164+
You can define the maximum number of attempts a job can consume within a supervisor's configuration:
165+
166+
```php
167+
'environments' => [
168+
'production' => [
169+
'supervisor-1' => [
170+
// ...
171+
'tries' => 10,
172+
],
173+
],
174+
],
175+
```
176+
177+
> [!NOTE]
178+
> This option is similar to the `--tries` option when using the Artisan command to process queues.
179+
180+
Adjusting the `tries` option is essential when using middlewares such as `WithoutOverlapping` or `RateLimited` because they consume attempts. To handle this, adjust the `tries` configuration value either at the supervisor level or by defining the `$tries` property on the job class.
181+
182+
If you don’t set the `tries` option, Horizon defaults to a single attempt, unless the job class defines `$tries`, which takes precedence over the Horizon configuration.
183+
184+
Setting `tries` or `$tries` to 0 allows unlimited attempts, which is ideal when the number of attempts is uncertain. To prevent endless failures, you can limit the number of exceptions allowed by setting the `$maxExceptions` property on the job class.
185+
186+
<a name="job-timeout"></a>
187+
### Job Timeout
188+
189+
Similarly, you can set a `timeout` value at the supervisor level, which specifies how many seconds a worker process can run a job before it's forcefully terminated. Once terminated, the job will either be retried or marked as failed, depending on your queue configuration:
190+
191+
```php
192+
'environments' => [
193+
'production' => [
194+
'supervisor-1' => [
195+
// ...¨
196+
'timeout' => 60,
197+
],
198+
],
199+
],
200+
```
201+
202+
> [!WARNING]
203+
> The `timeout` value should always be at least a few seconds shorter than the `retry_after` value defined in your `config/queue.php` configuration file. Otherwise, your jobs may be processed twice.
204+
205+
<a name="job-backoff"></a>
206+
### Job Backoff
207+
208+
You can define the `backoff` value at the supervisor level to specify how long Horizon should wait before retrying a job that encounters an unhandled exception:
209+
210+
```php
211+
'environments' => [
212+
'production' => [
213+
'supervisor-1' => [
214+
// ...
215+
'backoff' => 10,
216+
],
217+
],
218+
],
219+
```
220+
221+
You may also configure "exponential" backoffs by using an array for the `backoff` value. In this example, the retry delay will be 1 second for the first retry, 5 seconds for the second retry, 10 seconds for the third retry, and 10 seconds for every subsequent retry if there are more attempts remaining:
222+
223+
```php
224+
'environments' => [
225+
'production' => [
226+
'supervisor-1' => [
227+
// ...
228+
'backoff' => [1, 5, 10],
229+
],
230+
],
231+
],
232+
```
233+
187234
<a name="silenced-jobs"></a>
188235
### Silenced Jobs
189236

@@ -208,6 +255,174 @@ class ProcessPodcast implements ShouldQueue, Silenced
208255
}
209256
```
210257

258+
<a name="balancing-strategies"></a>
259+
## Balancing Strategies
260+
261+
Each supervisor can process one or more queues but unlike Laravel's default queue system, Horizon allows you to choose from three worker balancing strategies: `auto`, `simple`, and `false`.
262+
263+
<a name="auto-balancing"></a>
264+
### Auto Balancing
265+
266+
The `auto` strategy, which is the default strategy, adjusts the number of worker processes per queue based on the current workload of the queue. For example, if your `notifications` queue has 1,000 pending jobs while your `default` queue is empty, Horizon will allocate more workers to your `notifications` queue until the queue is empty.
267+
268+
When using the `auto` strategy, you may also configure the `minProcesses` and `maxProcesses` configuration options:
269+
270+
<div class="content-list" markdown="1">
271+
272+
- `minProcesses` defines the minimum number of worker processes per queue. This value must be greater than or equal to 1.
273+
- `maxProcesses` defines the maximum total number of worker processes Horizon may scale up to across all queues. This value should typically be greater than the number of queues multiplied by the `minProcesses` value. To prevent the supervisor from spawning any processes, you may set this value to 0.
274+
275+
</div>
276+
277+
For example, you may configure Horizon to maintain at least one process per queue and scale up to a total of 10 worker processes:
278+
279+
```php
280+
'environments' => [
281+
'production' => [
282+
'supervisor-1' => [
283+
'connection' => 'redis',
284+
'queue' => ['default', 'notifications'],
285+
'balance' => 'auto',
286+
'autoScalingStrategy' => 'time',
287+
'minProcesses' => 1,
288+
'maxProcesses' => 10,
289+
'balanceMaxShift' => 1,
290+
'balanceCooldown' => 3,
291+
],
292+
],
293+
],
294+
```
295+
296+
The `autoScalingStrategy` configuration option determines how Horizon will assign more worker processes to queues. You can choose between two strategies:
297+
298+
<div class="content-list" markdown="1">
299+
300+
- The `time` strategy will assign workers based on the total estimated amount of time it will take to clear the queue.
301+
- The `size` strategy will assign workers based on the total number of jobs on the queue.
302+
303+
</div>
304+
305+
The `balanceMaxShift` and `balanceCooldown` configuration values determine how quickly Horizon will scale to meet worker demand. In the example above, a maximum of one new process will be created or destroyed every three seconds. You are free to tweak these values as necessary based on your application's needs.
306+
307+
<a name="auto-queue-priorities"></a>
308+
#### Queue Priorities and Auto Balancing
309+
310+
When using the `auto` balancing strategy, Horizon does not enforce strict priority between queues. The order of queues in a supervisor's configuration does not affect how worker processes are assigned. Instead, Horizon relies on the selected `autoScalingStrategy` to dynamically allocate worker processes based on queue load.
311+
312+
For example, in the following configuration, the high queue is not prioritized over the default queue, despite appearing first in the list:
313+
314+
```php
315+
'environments' => [
316+
'production' => [
317+
'supervisor-1' => [
318+
// ...
319+
'queue' => ['high', 'default'],
320+
'minProcesses' => 1,
321+
'maxProcesses' => 10,
322+
],
323+
],
324+
],
325+
```
326+
327+
If you need to enforce a relative priority between queues, you may define multiple supervisors and explicitly allocate processing resources:
328+
329+
```php
330+
'environments' => [
331+
'production' => [
332+
'supervisor-1' => [
333+
// ...
334+
'queue' => ['default'],
335+
'minProcesses' => 1,
336+
'maxProcesses' => 10,
337+
],
338+
'supervisor-2' => [
339+
// ...
340+
'queue' => ['images'],
341+
'minProcesses' => 1,
342+
'maxProcesses' => 1,
343+
],
344+
],
345+
],
346+
```
347+
348+
In this example, the default `queue` can scale up to 10 processes, while the `images` queue is limited to one process. This configuration ensures that your queues can scale independently.
349+
350+
> [!NOTE]
351+
> When dispatching resource-intensive jobs, it's sometimes best to assign them to a dedicated queue with a limited `maxProcesses` value. Otherwise, these jobs could consume excessive CPU resources and overload your system.
352+
353+
<a name="simple-balancing"></a>
354+
### Simple Balancing
355+
356+
The `simple` strategy distributes worker processes evenly across the specified queues. With this strategy, Horizon does not automatically scale the number of worker processes. Rather, it uses a fixed number of processes:
357+
358+
```php
359+
'environments' => [
360+
'production' => [
361+
'supervisor-1' => [
362+
// ...
363+
'queue' => ['default', 'notifications'],
364+
'balance' => 'simple',
365+
'processes' => 10,
366+
],
367+
],
368+
],
369+
```
370+
371+
In the example above, Horizon will assign 5 processes to each queue, splitting the total of 10 evenly.
372+
373+
If you'd like to control the number of worker processes assigned to each queue individually, you can define multiple supervisors:
374+
375+
```php
376+
'environments' => [
377+
'production' => [
378+
'supervisor-1' => [
379+
// ...
380+
'queue' => ['default'],
381+
'balance' => 'simple',
382+
'processes' => 10,
383+
],
384+
'supervisor-notifications' => [
385+
// ...
386+
'queue' => ['notifications'],
387+
'balance' => 'simple',
388+
'processes' => 2,
389+
],
390+
],
391+
],
392+
```
393+
394+
With this configuration, Horizon will assign 10 processes to the `default` queue and 2 processes to the `notifications` queue.
395+
396+
<a name="no-balancing"></a>
397+
### No Balancing
398+
399+
When the `balance` option is set to `false`, Horizon processes queues strictly in the order they're listed, similar to Laravel’s default queue system. However, it will still scale the number of worker processes if jobs begin to accumulate:
400+
401+
```php
402+
'environments' => [
403+
'production' => [
404+
'supervisor-1' => [
405+
// ...
406+
'queue' => ['default', 'notifications'],
407+
'balance' => false,
408+
'minProcesses' => 1,
409+
'maxProcesses' => 10,
410+
],
411+
],
412+
],
413+
```
414+
415+
In the example above, jobs in the `default` queue are always prioritized over jobs in the `notifications` queue. For instance, if there are 1,000 jobs in `default` and only 10 in `notifications`, Horizon will fully process all `default` jobs before handling any from `notifications`.
416+
417+
You can control Horizon's ability to scale worker processes using the `minProcesses` and `maxProcesses` options:
418+
419+
<div class="content-list" markdown="1">
420+
421+
- `minProcesses` defines the minimum number of worker processes in total. This value must be greater than or equal to 1.
422+
- `maxProcesses` defines the maximum total number of worker processes Horizon may scale up to.
423+
424+
</div>
425+
211426
<a name="upgrading-horizon"></a>
212427
## Upgrading Horizon
213428

original-en/http-tests.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,9 @@ After making a test request to your application, the `dump`, `dumpHeaders`, and
278278
test('basic test', function () {
279279
$response = $this->get('/');
280280

281+
$response->dump();
281282
$response->dumpHeaders();
282-
283283
$response->dumpSession();
284-
285-
$response->dump();
286284
});
287285
```
288286

@@ -302,11 +300,9 @@ class ExampleTest extends TestCase
302300
{
303301
$response = $this->get('/');
304302

303+
$response->dump();
305304
$response->dumpHeaders();
306-
307305
$response->dumpSession();
308-
309-
$response->dump();
310306
}
311307
}
312308
```

original-en/middleware.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ Route::put('/post/{id}', function (string $id) {
451451
<a name="terminable-middleware"></a>
452452
## Terminable Middleware
453453

454-
Sometimes a middleware may need to do some work after the HTTP response has been sent to the browser. If you define a `terminate` method on your middleware and your web server is using FastCGI, the `terminate` method will automatically be called after the response is sent to the browser:
454+
Sometimes a middleware may need to do some work after the HTTP response has been sent to the browser. If you define a `terminate` method on your middleware and your web server is using [FastCGI](https://www.php.net/manual/en/install.fpm.php), the `terminate` method will automatically be called after the response is sent to the browser:
455455

456456
```php
457457
<?php

0 commit comments

Comments
 (0)