# Integration

Learn how to integrate Croct into your PHP project.

The fastest way to get started is through our [CLI](/reference/cli/installation). If you prefer to set it up manually, check out the [step-by-step instructions](/reference/sdk/php/manual-installation).

## Run the command \[#install]

The recommended way to install the SDK is to use the Croct CLI.

**Command to initialize your project**

```sh
croct init
```

## Initialize the SDK \[#initialize]

Add your credentials to a `.env` file in your project root:

**.env**

```bash
CROCT_APP_ID=<APPLICATION_ID>
CROCT_API_KEY=<API_KEY>
```

You can find the application ID and create an API key on the [Integration page](https://app.croct.com/redirect/organizations/-organization-/workspaces/-workspace-/applications/-application-/integration) of your application.

Then set up the SDK and hand off to the browser so personalization continues transparently on the client side:

**index.php**

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

$croct = Croct::fromDotenv();
$content = $croct->fetchContent('home-banner')->getContent();
Croct::emitCookies();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>My application</title>
</head>
<body>
    <h1><?= $content['headline'] ?></h1>
    <p><?= $content['tagline'] ?></p>

    <script src="https://cdn.croct.io/js/v1/lib/plug.js"></script>
    <script>croct.plug(<?= json_encode($croct->getPlugOptions()) ?>);</script>
</body>
</html>
```

The [`fromDotenv`](api/core/croct/from-dotenv) factory reads the credentials from your `.env` file and uses a cookie-based session store. Calling [`emitCookies`](api/core/croct/emit-cookies) writes the session cookies before any output, while [`getPlugOptions`](api/core/plug/get-plug-options) returns the configuration the [JavaScript SDK](/reference/sdk/javascript) needs to work transparently with the same session. For more details, see [Client-side setup](client-side-setup).

## Check your integration \[#check]

If you open your application now, it should start sending events.

To check if your integration is working, go to the [Integration page](https://app.croct.com/redirect/organizations/-organization-/workspaces/-workspace-/applications/-application-/integration) of your application.

![Integration status](/assets/reference/sdk/integration-status.png)

When working correctly, you should see a green bullet next to the **Status** label saying **"Received traffic in the past 24 hours"**. If you still do not see this message after a few minutes, see the [Troubleshooting](troubleshooting) reference.

## Explore

- [PHP SDK](https://github.com/croct-tech/plug-php): Explore and contribute to the SDK development on GitHub.
- [Troubleshooting](troubleshooting): Identify and resolve issues with your integration.
