> ## Documentation Index
> Fetch the complete documentation index at: https://docs.law4devs.eu/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install the Law4Devs PHP SDK and make your first API call.

## Requirements

* PHP 8.1 or later
* `ext-curl` and `ext-json` extensions (enabled by default in most PHP installations)
* No runtime dependencies — zero third-party packages required

## Install

```bash theme={null}
composer require law4devs/law4devs
```

To pin to a specific version:

```bash theme={null}
composer require law4devs/law4devs:^0.1
```

## First Call

```php theme={null}
<?php

require_once 'vendor/autoload.php';

use Law4Devs\Client;

$client = new Client(apiKey: $_ENV['LAW4DEVS_API_KEY']);
$page = $client->frameworks->list();
echo $page->data[0]->name; // e.g. "Cyber Resilience Act"
```

## Configuration

```php theme={null}
use Law4Devs\Client;

$client = new Client(
    apiKey:     $_ENV['LAW4DEVS_API_KEY'],
    baseUrl:    'https://api.law4devs.eu/v1', // default
    timeout:    30,   // seconds, default 30
    maxRetries: 3,    // retries on 429/5xx, default 3
);
```

| Option       | Type     | Default        | Description                  |
| ------------ | -------- | -------------- | ---------------------------- |
| `apiKey`     | `string` | `''`           | **Required.** Your API key   |
| `baseUrl`    | `string` | Production URL | Override for dev environment |
| `timeout`    | `int`    | `30`           | Request timeout in seconds   |
| `maxRetries` | `int`    | `3`            | Retries on 429/5xx           |

## Environment Variable

```bash theme={null}
export LAW4DEVS_API_KEY="your-key"
```

```php theme={null}
use Law4Devs\Client;

$client = new Client(apiKey: getenv('LAW4DEVS_API_KEY'));
```

<Warning>
  Never hardcode your API key in source code or commit it to version control.
</Warning>

## Verify the Install

```bash theme={null}
LAW4DEVS_API_KEY=your-key php -r "
require 'vendor/autoload.php';
\$c = new \Law4Devs\Client(apiKey: getenv('LAW4DEVS_API_KEY'));
echo \$c->frameworks->list()->meta->total . ' frameworks\n';
"
```
