Skip to content

Commit d023111

Browse files
committed
2025-10-06までの原文変更点反映。
1 parent f366d59 commit d023111

24 files changed

+464
-64
lines changed

original-en/authentication.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ Next, we will define a route that will handle the form request from the "confirm
567567
```php
568568
use Illuminate\Http\Request;
569569
use Illuminate\Support\Facades\Hash;
570-
use Illuminate\Support\Facades\Redirect;
571570

572571
Route::post('/confirm-password', function (Request $request) {
573572
if (! Hash::check($request->password, $request->user()->password)) {

original-en/broadcasting.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,3 +1697,22 @@ channel().notification((notification) => {
16971697
```
16981698
16991699
In this example, all notifications sent to `App\Models\User` instances via the `broadcast` channel would be received by the callback. A channel authorization callback for the `App.Models.User.{id}` channel is included in your application's `routes/channels.php` file.
1700+
1701+
<a name="stop-listening-for-notifications"></a>
1702+
#### Stop Listening for Notifications
1703+
1704+
If you would like to stop listening to notifications without [leaving the channel](#leaving-a-channel), you may use the `stopListeningForNotification` method:
1705+
1706+
```js
1707+
const callback = (notification) => {
1708+
console.log(notification.type);
1709+
}
1710+
1711+
// Start listening...
1712+
Echo.private(`App.Models.User.${userId}`)
1713+
.notification(callback);
1714+
1715+
// Stop listening (callback must be the same)...
1716+
Echo.private(`App.Models.User.${userId}`)
1717+
.stopListeningForNotification(callback);
1718+
```

original-en/database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ DB::transaction(function () {
391391
DB::update('update users set votes = 1');
392392

393393
DB::delete('delete from posts');
394-
}, 5);
394+
}, attempts: 5);
395395
```
396396

397397
<a name="manually-using-transactions"></a>

original-en/eloquent-factories.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ If you already have model instances that you would like to be attached to the mo
505505
```php
506506
$roles = Role::factory()->count(3)->create();
507507

508-
$user = User::factory()
508+
$users = User::factory()
509509
->count(3)
510510
->hasAttached($roles, ['active' => true])
511511
->create();
@@ -555,7 +555,7 @@ Polymorphic "many to many" (`morphToMany` / `morphedByMany`) relationships may b
555555
use App\Models\Tag;
556556
use App\Models\Video;
557557

558-
$videos = Video::factory()
558+
$video = Video::factory()
559559
->hasAttached(
560560
Tag::factory()->count(3),
561561
['public' => true]
@@ -566,7 +566,7 @@ $videos = Video::factory()
566566
Of course, the magic `has` method may also be used to create polymorphic "many to many" relationships:
567567

568568
```php
569-
$videos = Video::factory()
569+
$video = Video::factory()
570570
->hasTags(3, ['public' => true])
571571
->create();
572572
```

original-en/http-client.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- [Guzzle Middleware](#guzzle-middleware)
1212
- [Guzzle Options](#guzzle-options)
1313
- [Concurrent Requests](#concurrent-requests)
14+
- [Request Pooling](#request-pooling)
15+
- [Request Batching](#request-batching)
1416
- [Macros](#macros)
1517
- [Testing](#testing)
1618
- [Faking Responses](#faking-responses)
@@ -500,6 +502,9 @@ public function boot(): void
500502

501503
Sometimes, you may wish to make multiple HTTP requests concurrently. In other words, you want several requests to be dispatched at the same time instead of issuing the requests sequentially. This can lead to substantial performance improvements when interacting with slow HTTP APIs.
502504

505+
<a name="request-pooling"></a>
506+
### Request Pooling
507+
503508
Thankfully, you may accomplish this using the `pool` method. The `pool` method accepts a closure which receives an `Illuminate\Http\Client\Pool` instance, allowing you to easily add requests to the request pool for dispatching:
504509

505510
```php
@@ -552,6 +557,71 @@ $responses = Http::pool(fn (Pool $pool) => [
552557
]);
553558
```
554559

560+
<a name="request-batching"></a>
561+
### Request Batching
562+
563+
Another way of working with concurrent requests in Laravel is to use the `batch` method. Like the `pool` method, it accepts a closure which receives an `Illuminate\Http\Client\Batch` instance, allowing you to easily add requests to the request pool for dispatching, but it also allows you to define completion callbacks:
564+
565+
```php
566+
use Illuminate\Http\Client\Batch;
567+
use Illuminate\Http\Client\RequestException;
568+
use Illuminate\Http\Client\Response;
569+
use Illuminate\Support\Facades\Http;
570+
571+
$responses = Http::batch(fn (Batch $batch) => [
572+
$batch->get('http://localhost/first'),
573+
$batch->get('http://localhost/second'),
574+
$batch->get('http://localhost/third'),
575+
])->before(function (Batch $batch) {
576+
// The batch has been created but no requests have been initialized...
577+
})->progress(function (Batch $batch, int|string $key, Response $response) {
578+
// An individual request has completed successfully...
579+
})->then(function (Batch $batch, array $results) {
580+
// All requests completed successfully...
581+
})->catch(function (Batch $batch, int|string $key, Response|RequestException $response) {
582+
// First batch request failure detected...
583+
})->finally(function (Batch $batch, array $results) {
584+
// The batch has finished executing...
585+
})->send();
586+
```
587+
588+
Like the `pool` method, you can use the `as` method to name your requests:
589+
590+
```php
591+
$responses = Http::batch(fn (Batch $batch) => [
592+
$batch->as('first')->get('http://localhost/first'),
593+
$batch->as('second')->get('http://localhost/second'),
594+
$batch->as('third')->get('http://localhost/third'),
595+
])->send();
596+
```
597+
598+
After a `batch` is started by calling the `send` method, you can't add new requests to it. Trying to do so will result in a `Illuminate\Http\Client\BatchInProgressException` exception being thrown.
599+
600+
<a name="inspecting-batches"></a>
601+
#### Inspecting Batches
602+
603+
The `Illuminate\Http\Client\Batch` instance that is provided to batch completion callbacks has a variety of properties and methods to assist you in interacting with and inspecting a given batch of requests:
604+
605+
```php
606+
// The number of requests assigned to the batch...
607+
$batch->totalRequests;
608+
609+
// The number of requests that have not been processed yet...
610+
$batch->pendingRequests;
611+
612+
// The number of requests that have failed...
613+
$batch->failedRequests;
614+
615+
// The number of requests that have been processed thus far...
616+
$batch->processedRequests();
617+
618+
// Indicates if the batch has finished executing...
619+
$batch->finished();
620+
621+
// Indicates if the batch has request failures...
622+
$batch->hasFailures();
623+
```
624+
555625
<a name="macros"></a>
556626
## Macros
557627

original-en/mcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- [Prompt Dependency Injection](#prompt-dependency-injection)
2323
- [Conditional Prompt Registration](#conditional-prompt-registration)
2424
- [Prompt Responses](#prompt-responses)
25-
- [Resources](#creating-resources)
25+
- [Resources](#resources)
2626
- [Creating Resources](#creating-resources)
2727
- [Resource URI and MIME Type](#resource-uri-and-mime-type)
2828
- [Resource Request](#resource-request)

original-en/octane.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,23 @@ php artisan octane:start
258258

259259
By default, Octane will start the server on port 8000, so you may access your application in a web browser via `http://localhost:8000`.
260260

261+
<a name="keeping-octane-running-in-production"></a>
262+
#### Keeping Octane Running in Production
263+
264+
If you are deploying your Octane application to production, you should use a process monitor such as Supervisor to ensure the Octane server stays running. A sample Supervisor configuration file for Octane might look like the following:
265+
266+
```ini
267+
[program:octane]
268+
process_name=%(program_name)s_%(process_num)02d
269+
command=php /home/forge/example.com/artisan octane:start --server=frankenphp --host=127.0.0.1 --port=8000
270+
autostart=true
271+
autorestart=true
272+
user=forge
273+
redirect_stderr=true
274+
stdout_logfile=/home/forge/example.com/storage/logs/octane.log
275+
stopwaitsecs=3600
276+
```
277+
261278
<a name="serving-your-application-via-https"></a>
262279
### Serving Your Application via HTTPS
263280

original-en/queues.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,67 @@ class ProcessSubscriptionRenewal implements ShouldQueue
14701470
}
14711471
```
14721472

1473+
<a name="fifo-listeners-mail-and-notifications"></a>
1474+
#### FIFO Listeners, Mail, and Notifications
1475+
1476+
When utilizing FIFO queues, you will also need to define message groups on listeners, mail, and notifications. Alternatively, you can dispatch queued instances of these objects to a non-FIFO queue.
1477+
1478+
To define the message group for a [queued event listener](/docs/{{version}}/events#queued-event-listeners), define a `messageGroup` method on the listener. You may also optionally define a `deduplicationId` method:
1479+
1480+
```php
1481+
<?php
1482+
1483+
namespace App\Listeners;
1484+
1485+
use App\Events\OrderShipped;
1486+
1487+
class SendShipmentNotification
1488+
{
1489+
// ...
1490+
1491+
/**
1492+
* Get the job's message group.
1493+
*/
1494+
public function messageGroup(): string
1495+
{
1496+
return "shipments";
1497+
}
1498+
1499+
/**
1500+
* Get the job's deduplication ID.
1501+
*/
1502+
public function deduplicationId(): string
1503+
{
1504+
return "shipment-notification-{$this->shipment->id}";
1505+
}
1506+
}
1507+
```
1508+
1509+
When sending a [mail message](/docs/{{version}}/mail) that is going to be queued on a FIFO queue, you should invoke the `onGroup` method and optionally the `withDeduplicator` method when sending the notification:
1510+
1511+
```php
1512+
use App\Mail\InvoicePaid;
1513+
use Illuminate\Support\Facades\Mail;
1514+
1515+
$invoicePaid = (new InvoicePaid($invoice))
1516+
->onGroup('invoices')
1517+
->withDeduplicator(fn () => 'invoices-'.$invoice->id);
1518+
1519+
Mail::to($request->user())->send($invoicePaid);
1520+
```
1521+
1522+
When sending a [notification](/docs/{{version}}/notifications) that is going to be queued on a FIFO queue, you should invoke the `onGroup` method and optionally the `withDeduplicator` method when sending the notification:
1523+
1524+
```php
1525+
use App\Notifications\InvoicePaid;
1526+
1527+
$invoicePaid = (new InvoicePaid($invoice))
1528+
->onGroup('invoices')
1529+
->withDeduplicator(fn () => 'invoices-'.$invoice->id);
1530+
1531+
$user->notify($invoicePaid);
1532+
```
1533+
14731534
<a name="error-handling"></a>
14741535
### Error Handling
14751536

@@ -1563,10 +1624,10 @@ class SyncChatHistory implements ShouldQueue
15631624
*/
15641625
public function handle(): void
15651626
{
1566-
$user->authorize('sync-chat-history');
1627+
$this->user->authorize('sync-chat-history');
15671628

15681629
$response = Http::throw()->get(
1569-
"https://chat.laravel.test/?user={$user->uuid}"
1630+
"https://chat.laravel.test/?user={$this->user->uuid}"
15701631
);
15711632

15721633
// ...
@@ -1885,6 +1946,16 @@ $batch = Bus::batch([
18851946
})->allowFailures()->dispatch();
18861947
```
18871948

1949+
You may optionally provide a closure to the `allowFailures` method, which will be executed on each job failure:
1950+
1951+
```php
1952+
$batch = Bus::batch([
1953+
// ...
1954+
])->allowFailures(function (Batch $batch, $exception) {
1955+
// Handle individual job failures...
1956+
})->dispatch();
1957+
```
1958+
18881959
<a name="retrying-failed-batch-jobs"></a>
18891960
#### Retrying Failed Batch Jobs
18901961

original-en/routing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,29 @@ RateLimiter::for('uploads', function (Request $request) {
945945
});
946946
```
947947

948+
<a name="response-base-rate-limiting"></a>
949+
#### Response-Based Rate Limiting
950+
951+
In addition to rate limiting incoming requests, Laravel allows you to rate limit based on the response using the `after` method. This is useful when you only want to count certain responses toward the rate limit, such as validation errors, 404 responses, or other specific HTTP status codes.
952+
953+
The `after` method accepts a closure that receives the response and should return `true` if the response should be counted toward the rate limit, or `false` if it should be ignored. This is particularly useful for preventing enumeration attacks by limiting consecutive 404 responses, or allowing users to retry requests that fail validation without exhausting their rate limit on an endpoint that should only throttle successful operations:
954+
955+
```php
956+
use Illuminate\Cache\RateLimiting\Limit;
957+
use Illuminate\Http\Request;
958+
use Illuminate\Support\Facades\RateLimiter;
959+
use Symfony\Component\HttpFoundation\Response;
960+
961+
RateLimiter::for('resource-not-found', function (Request $request) {
962+
return Limit::perMinute(10)
963+
->by($request->user()?->id ?: $request->ip())
964+
->after(function (Response $response) {
965+
// Only count 404 responses toward the rate limit to prevent enumeration...
966+
return $response->status() === 404;
967+
});
968+
});
969+
```
970+
948971
<a name="attaching-rate-limiters-to-routes"></a>
949972
### Attaching Rate Limiters to Routes
950973

0 commit comments

Comments
 (0)