master

laravel/framework

Last updated at: 29/12/2023 09:25

Response.php

TLDR

This file is a part of the Illuminate\Support\Facades namespace and contains the Response class. The Response class is a facade for the ResponseFactory, which is responsible for creating HTTP responses. The class provides various methods for creating and manipulating responses.

Classes

Response

The Response class serves as a facade for the ResponseFactory. It provides a set of static methods for creating and manipulating HTTP responses. Some of the methods available in this class include:

  • make: Creates a response instance with the given content, status, and headers.
  • noContent: Creates a response with a status code of 204 and no content.
  • view: Creates a response for rendering a view with optional data, status, and headers.
  • json: Creates a response for outputting JSON data with optional status, headers, and options.
  • jsonp: Creates a JSONP response with the specified callback function.
  • stream: Creates a response that streams the output from a callback function.
  • streamDownload: Creates a response for streaming a file download with optional filename and disposition.
  • download: Creates a response for downloading a file with optional filename and disposition.
  • file: Creates a response for serving a file.
  • redirectTo: Creates a response that redirects to the specified path.
  • redirectToRoute: Creates a response that redirects to the specified route.
  • redirectToAction: Creates a response that redirects to the specified action.
  • redirectGuest: Creates a response that redirects to the specified path for unauthenticated users.
  • redirectToIntended: Creates a response that redirects to the intended path or the specified default path.
  • macro: Registers a new macro for the Response class.
  • mixin: Mixes an object into the Response class.
  • hasMacro: Checks if a macro is registered for the Response class.
  • flushMacros: Flushes all registered macros for the Response class.

END

<?php

namespace Illuminate\Support\Facades;

use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;

/**
 * @method static \Illuminate\Http\Response make(mixed $content = '', int $status = 200, array $headers = [])
 * @method static \Illuminate\Http\Response noContent(int $status = 204, array $headers = [])
 * @method static \Illuminate\Http\Response view(string|array $view, array $data = [], int $status = 200, array $headers = [])
 * @method static \Illuminate\Http\JsonResponse json(mixed $data = [], int $status = 200, array $headers = [], int $options = 0)
 * @method static \Illuminate\Http\JsonResponse jsonp(string $callback, mixed $data = [], int $status = 200, array $headers = [], int $options = 0)
 * @method static \Symfony\Component\HttpFoundation\StreamedResponse stream(callable $callback, int $status = 200, array $headers = [])
 * @method static \Symfony\Component\HttpFoundation\StreamedResponse streamDownload(callable $callback, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')
 * @method static \Symfony\Component\HttpFoundation\BinaryFileResponse download(\SplFileInfo|string $file, string|null $name = null, array $headers = [], string|null $disposition = 'attachment')
 * @method static \Symfony\Component\HttpFoundation\BinaryFileResponse file(\SplFileInfo|string $file, array $headers = [])
 * @method static \Illuminate\Http\RedirectResponse redirectTo(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
 * @method static \Illuminate\Http\RedirectResponse redirectToRoute(string $route, mixed $parameters = [], int $status = 302, array $headers = [])
 * @method static \Illuminate\Http\RedirectResponse redirectToAction(array|string $action, mixed $parameters = [], int $status = 302, array $headers = [])
 * @method static \Illuminate\Http\RedirectResponse redirectGuest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
 * @method static \Illuminate\Http\RedirectResponse redirectToIntended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)
 * @method static void macro(string $name, object|callable $macro)
 * @method static void mixin(object $mixin, bool $replace = true)
 * @method static bool hasMacro(string $name)
 * @method static void flushMacros()
 *
 * @see \Illuminate\Routing\ResponseFactory
 */
class Response extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return ResponseFactoryContract::class;
    }
}