# PHP

Learn how to manually set up the Storyblok integration in a PHP project.

The following guide gives you a step-by-step overview of how to install and set up the Storyblok integration in your PHP project.

> **Speed up your integration!**
>
> On supported PHP frameworks, the CLI can automate the integration process for you. Check out the [integration guide](../integration) to get started faster.

## Install the Croct SDK \[#prerequisites]

Install and configure the [SDK](/reference/sdk) that corresponds to your project's framework. The Storyblok integration acts as a bridge between the SDK and Storyblok, so it needs the SDK to be set up first.

## Install the Storyblok integration \[#install]

Run the following command to install the integration:

**Command to install the integration**

```sh
composer require croct/plug-storyblok
```

## Connect the integration \[#connect]

Connect Croct to your Storyblok Stories API yourself, or let a supported framework wire it for you.

### Manual setup

Wrap your Storyblok Stories API with [`CroctStoriesApi`](../api/php/croct-stories-api), passing your Croct SDK instance. Every story you read through the decorated API has its linked blocks resolved automatically.

```php
<?php
use Croct\Plug\Croct;
use Croct\Plug\Storyblok\CroctStoriesApi;
use Storyblok\Api\StoriesApi;
use Storyblok\Api\StoryblokClient;

$plug = Croct::fromDotenv();

$client = new StoryblokClient(
    baseUri: 'https://api.storyblok.com',
    token: 'YOUR_ACCESS_TOKEN',
);

$stories = new CroctStoriesApi(new StoriesApi($client), $plug);

$response = $stories->bySlug('home');
```

### Automatic setup

On supported frameworks, the integration activates on its own. After you install `croct/plug-storyblok`, it wraps your Storyblok Stories API automatically, with personalization enabled by default. There is no decorator to wire and no configuration to add.

> **Requires a Storyblok Stories API**
>
> The integration wraps the Storyblok Stories API exposed by your framework's official Storyblok package. Until that package is installed, personalization stays inactive.

## Explore

- [CLI](../integration): Learn how to use our CLI to get started faster.
- [Storyblok SDK](https://github.com/croct-tech/plug-storyblok-php): Explore and contribute to the integration development on GitHub.
