# fromServerRequest

Learn how to create a storage from a PSR-7 server request.

This static method creates a storage from a [PSR-7](https://www.php-fig.org/psr/psr-7/) server request, reading the cookies from the request.

Use it when integrating with a framework that exposes the incoming request as a PSR-7 object.

## Signature

This method has the following signature:

```php
public static function fromServerRequest(ServerRequest $request, ?CookieConfiguration $configuration = null, ?int $now = null): self
```

This method returns a new instance initialized with the client ID and user token read from the request's cookies.

## Example

Here is a basic example of how to use this method:

```php
<?php
use Croct\Plug\CookieStorage;

$storage = CookieStorage::fromServerRequest($request);
```

## Parameters

The following list describes the supported parameters:

- `request`: `ServerRequest`

  The [PSR-7](https://www.php-fig.org/psr/psr-7/) server request to read the cookies from.

- `configuration`: [`CookieConfiguration`](/reference/sdk/php/api/storage/cookie-configuration) (optional) (default: null)

  The cookie configuration, such as the cookie names and domain. The default is `null`, which uses the standard configuration.

- `now`: `integer` (optional) (default: null)

  The current time as a Unix timestamp in seconds, used to compute the cookie expiration. The default is `null`, which uses the current time.
