PHP code example of alxmsl / psr-7

1. Go to this page and download the library: Download alxmsl/psr-7 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alxmsl / psr-7 example snippets


interface RequestInterface extends MessageInterface {
    /**
     * @return string
     */
    public function getRequestTarget();

    /**
     * @param mixed $requestTarget
     * @return self
     */
    public function withRequestTarget($requestTarget);

    /**
     * @return string Returns the request method.
     */
    public function getMethod();

    /**
     * @param string $method Case-sensitive method.
     * @return self
     * @throws InvalidArgumentException for invalid HTTP methods.
     */
    public function withMethod($method);

    /**
     * @return UriInterface Returns a UriInterface instance representing the URI of the request.
     */
    public function getUri();

    /**
     * @param UriInterface $uri New request URI to use.
     * @param bool $preserveHost Preserve the original state of the Host header.
     * @return self
     */
    public function withUri(UriInterface $uri, $preserveHost = false);
}

interface RequestInterface extends MessageInterface {
    /**
     * @return string
     */
    public function getRequestTarget(): string;

    /**
     * @param mixed $requestTarget
     * @return self
     */
    public function withRequestTarget(mixed $requestTarget): RequestInterface;

    /**
     * @return string Returns the request method.
     */
    public function getMethod(): string;

    /**
     * @param string $method Case-sensitive method.
     * @return self
     * @throws InvalidArgumentException for invalid HTTP methods.
     */
    public function withMethod(string $method): RequestInterface;

    /**
     * @return UriInterface Returns a UriInterface instance representing the URI of the request.
     */
    public function getUri(): UriInterface;

    /**
     * @param UriInterface $uri New request URI to use.
     * @param bool $preserveHost Preserve the original state of the Host header.
     * @return self
     */
    public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface;
}