middleware changedcli-sdks-libraries/middleware
Nearest release: v2.1.310, published 2 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+16added
Lines−12removed
From line
130
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits8to this page, all time
The whole hunk
from line 130, old and new numbered
/
from line 130
130130 .build();
131131 ```
132132
133 ```php PHP
134 $loggingMiddleware = function (RequestInterface $request, callable $next): ResponseInterface {
135 // Before the request
136 error_log("-> {$request->getMethod()} {$request->getUri()}");
133 <CodeGroupItem>
134 ```php PHP
135 $loggingMiddleware = function (RequestInterface $request, callable $next): ResponseInterface {
136 // Before the request
137 error_log("-> {$request->getMethod()} {$request->getUri()}");
137138
138 // Forward the request to the rest of the chain
139 $response = $next($request);
139 // Forward the request to the rest of the chain
140 $response = $next($request);
140141
141 // After the request
142 error_log("<- {$response->getStatusCode()}");
142 // After the request
143 error_log("<- {$response->getStatusCode()}");
143144
144 return $response;
145 };
145 return $response;
146 };
146147
147 $client = new Client(requestOptions: ['middleware' => [$loggingMiddleware]]);
148 ```
148 $client = new Client(requestOptions: ['middleware' => [$loggingMiddleware]]);
149 ```
150
151 For middleware classes, the request options argument, and how middleware interacts with retries, errors, and request signing, see [Middleware in the PHP SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/php#middleware).
152 </CodeGroupItem>
149153
150154 ```ruby Ruby
151155 logging_middleware = lambda do |request, call_next|
No line in this hunk matches that.