Request Data & Replies
The Request and Response objects a Laravel handler uses: input, uploads, the session, views, JSON, redirects, streams and API resources. Interviewers use them to check everyday handler fluency.
on this pageshowhide
explore
- Input Retrieval & Old Input6 questions
- Uploaded Files to Disks5 questions
- Session Drivers & Flash5 questions
- Views, JSON & Downloads6 questions
- Redirects & Intended URLs5 questions
- Streamed Output & SSE5 questions
- API Resource Classes5 questions
questions
page 2 of 2A Laravel app's Cookie::queue() call works on web routes but sets nothing on an api.php route, and ->withCookie() on a download() response crashes; why?
basics
~10 sQueued cookies are copied onto responses by AddQueuedCookiesToResponse, which is in the web group but not the api group. withCookie() comes from Laravel's ResponseTrait, which Symfony's BinaryFileResponse returned by download() does not use.
In a Laravel quote wizard, two concurrent requests on one session each save a step and one change disappears; why, and how does ->block() help?
basics
~20 sLaravel loads the session when a request starts and writes the whole payload back at the end, unlocked, so the later of two overlapping requests overwrites the other's change. ->block() on the routes serialises them with a per-session cache lock.
In a Laravel streamed response, why do session writes inside the stream callback get lost, and what happens to an exception thrown there?
basics
~20 sA streamed response's callback runs during send(), after the HTTP kernel and all middleware, including StartSession's save, have finished. Session changes made there are never persisted, and an exception cannot change the already-sent 200 status.
For a Laravel sales report of a million rows, when do you stream it in the request, and when do you generate it in a queued job instead?
basics
~20 sStream with streamDownload() when the export finishes within about a minute and the user waits for it. Queue a job that writes the file to a disk and sends a link when it runs longer, must survive failures, or many users export at once.
A Laravel dating app rejects large profile photos, sometimes with a 413 PostTooLargeException and sometimes with 'The photo failed to upload.'; why two symptoms?
basics
~20 sA body over post_max_size is stopped by the global ValidatePostSize middleware with a 413 PostTooLargeException. A file over upload_max_filesize but inside post_max_size reaches the controller as an invalid UploadedFile, and validation reports it as failed to upload.
In Laravel, how do Response::macro() and a class implementing Responsable each let you reuse one response shape across controllers?
basics
~10 sResponse::macro('name', fn) adds a method to the response factory, so response()->name(...) builds the shared shape anywhere. A Responsable class implements toResponse($request), and the router calls it when a controller returns that object.
Laravel 13's session config sets serialization to json; what does that change about stored values, and what happens when an upgraded app switches?
basics
~20 sWith 'serialization' => 'json', the session payload is json_encode'd, so objects such as models or value objects come back as plain arrays. It removes PHP unserialize() from the session path; switching an existing app from php invalidates every active session.
showing 31–37 of 37