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.
On supported PHP frameworks, the CLI can automate the integration process for you. Check out the integration guide to get started faster.
Install the Croct SDK
Install and configure the 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
Run the following command to install the integration:
composer require croct/plug-storyblokConnect the integration
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, passing your Croct SDK instance. Every story you read through the decorated API has its linked blocks resolved automatically.
<?phpuse 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.
The integration wraps the Storyblok Stories API exposed by your framework’s official Storyblok package. Until that package is installed, personalization stays inactive.