Laravel

Responses

Response documentation comes from analyzing what your routes actually return. Besides plain arrays, models, collections and resources, PHP autodoc-laravel understands the common Laravel response types.

JSON responses

response()->json(...) is resolved to an application/json response with the schema of whatever you pass in - including nested query results, collections and resources:

return response()->json([
    'user' => User::find(1),
    'active' => true,
]);

Views

A route that returns a view - Illuminate\View\View or any Renderable - is documented as a text/html response with a string body:

return view('welcome');

Redirects

A returned Illuminate\Http\RedirectResponse is documented as a 302 response with a text/html body:

return redirect('/dashboard');

Service container

The app() helper is resolved during analysis. app() without arguments has the Illuminate\Foundation\Application type, and app(SomeService::class) resolves to an instance of that class, so chained method calls on the resolved service keep their return types:

return response()->json(
    app(ReportGenerator::class)->generate()
);

String binding names like app('cache') are left to regular code analysis.

Previous
Collections