Download the PHP package storyblok/symfony-bundle without Composer

On this page you can find all versions of the php package storyblok/symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package symfony-bundle

Storyblok Symfony Bundle

Co-created with SensioLabs, the creators of Symfony.

Branch PHP Code Coverage
master PHP codecov

A Symfony bundle to integrate the Storyblok headless CMS with your Symfony application.

This bundle leverages the storyblok/php-content-api-client, a type-safe PHP SDK for Storyblok. It configures the Storyblok client and provides a Symfony Profiler extension for easier debugging and monitoring of Storyblok API interactions.

Installation

To install the bundle run:

Configuration

Symfony Flex

If you are using symfony/flex, the bundle will be automatically enabled and the configuration files will be added to your project.

Manual Configuration

If symfony/flex is not available, or you prefer manual setup, follow these steps:

  1. Add the Configuration Add the following configuration to your config/packages/storyblok.yaml:

    If you want to use the AssetsApi, you can also add the following configuration:

  2. Set Environment Variables Define the necessary environment variables in your .env file:

Usage

API Usage

After setting up the bundle, you can use the Storyblok client within your Symfony application to interact with the Storyblok CMS API.

For detailed usage and examples, please refer to the Storyblok API SDK documentation.

Versions (draft and published)

Storyblok allows you to work with two versions of your content: draft and published. By default, the bundle uses the published version. If you want to use the draft version, you can set the version parameter in the configuration:

Webhooks

Storyblok Webhooks allow your Symfony application to react to events like content changes. This bundle provides easy setup for handling these Webhooks.

Configuration

To enable Webhooks, add the following route to your application:

This will make a route available at /storyblok/webhook to receive Webhook requests. For more details on how Webhooks work, check the Storyblok Webhooks Documentation.

Verifying Webhook Signatures (Security)

For security, you can enable the verification of Webhook signatures to ensure that the requests come from Storyblok. This is done by configuring a webhook_secret:

You'll need to set this secret in your .env file:

Once enabled, the bundle will automatically validate each Webhook request against this secret.

Handling Webhook Events

To process Webhooks, implement the WebhookHandlerInterface. The bundle automatically registers any classes implementing this interface as Webhook handlers, no additional service configuration is required.

Example Webhook Handler

Here's an example of a Webhook handler that purges a Varnish cache whenever certain events occur (e.g., content published or deleted):

Best Practices

This approach provides a streamlined and secure way to handle Webhooks from Storyblok, allowing your Symfony application to react to changes effectively. For more details and use cases, you can always refer to the Storyblok API SDK documentation.

Auto resolve relations

If you want to update relations automatically, you can enable this with the following configuration:

This will replace StoriesApi to StoriesResolvedApi. The StoriesResolvedApi will automatically resolve relations.

[!WARNING] Maximum 50 different relations can be resolved in one request. See Storyblok docs for more information

Auto resolve links

If you want to update links automatically, you can enable this with the following configuration:

This will replace StoriesApi to StoriesResolvedApi. The StoriesResolvedApi will automatically resolve relations.

[!WARNING] Maximum 500 different links can be resolved in one request depending also on the type you sent in the request. See Storyblok docs for more information

Content Type Handling & Routing

The bundle provides a convenient way to handle Storyblok content types and integrate them into your Symfony routing.

Create a Content Type object

A content type object is a PHP class that represents a Storyblok content type. For example the following code

[!TIP] Consider using the ValueObjectTrait included in this bundle to streamline the handling of Storyblok API responses. Real-world content data is often inconsistent — keys may be missing, values may have unexpected formats, or fields might be empty. The helper methods in this trait handle these edge cases for you, allowing you to write clean, defensive, and readable code with minimal boilerplate.

Read more →

By default, the content type technical name is derived from the class name, converted to snake_case. If you want to use a different name, you can override the type() static method:

This will affect the request to the Storyblok API, which will now look for the content type with the technical name my-custom-type-name.

[!WARNING] Be sure that your content type in Storyblok has the same technical name as defined in your class, otherwise the controller will not be able to resolve the content type correctly and will return a 404 error.

Register your Symfony controller

To register your Symfony controller as a Storyblok content type controller, use the #[AsContentTypeController] attribute.

In case you need a dedicated controller for a specific slug but also need one for the content type itself you can add the slug argument to the #[AsContentTypeController] attribute.

Controllers marked with the #[AsContentTypeController] attribute will be tagged with storyblok.content_type.controller and controller.service_arguments.

Caching

The bundle provides a global caching configuration to enable HTTP caching directives, which are disabled by default. We strongly recommend enabling these in prod environment. When you use symfony flex your configuration should be automatically added to your config/packages/storyblok.yaml file.

In case you need a specific caching configuration for a specific controller you can use Symfony's #[Cache] attribute or modifying the Response object directly. This will cause that the global configuration is being ignored.

Fallback to Parent Routes (ascending_redirect_fallback)

When working with nested Storyblok content structures, it’s possible that users might request a URL path that doesn’t correspond to a specific published content entry—for example, a section overview like /blog/author.

To provide a more graceful fallback behavior, the Storyblok Symfony Bundle introduces an ascending redirect fallback feature that can be enabled via configuration:

When this option is enabled, the bundle will automatically redirect upward in the content tree until it finds a valid route, instead of immediately returning a 404 Not Found.

Given the following content structure in Storyblok:

If a user visits /blog/author, and this route does not exist, the bundle will attempt to redirect to its closest existing parent route. In this case, it would redirect to /blog.

This provides a smoother user experience by guiding users to relevant content rather than showing a 404 error.

If no valid parent route can be found, a standard 404 response will still be returned.

Block Registration with #[AsBlock]

You can register Storyblok blocks using the #[AsBlock] attribute.

The name and template parameters are optional, you will find their defaults in the following section.

Usage

[!TIP] Consider using the ValueObjectTrait included in this bundle to streamline the handling of Storyblok API responses. Real-world content data is often inconsistent — keys may be missing, values may have unexpected formats, or fields might be empty. The helper methods in this trait handle these edge cases for you, allowing you to write clean, defensive, and readable code with minimal boilerplate.

Read more →

To define a block, use the attribute on a class:

Attribute Parameters

Parameter Type Required? Description
name string No The block name used in Storyblok. Defaults to the class name converted to snake_case.
template string No The Twig template for rendering the block. Defaults to blocks/{name}.html.twig.

Customizing the Default Template Path

You can change the default template path structure by configuring it in storyblok.yaml:

Rendering Blocks in Twig

A new render_block Twig filter allows easy rendering of Storyblok blocks:

This ensures dynamic rendering of Storyblok components with minimal effort.

Rich Text Rendering

This bundle provides a convenient rich_text Twig filter to render Storyblok Rich Text fields using the storyblok/php-tiptap-extension library. You can directly use the rich_text filter in your Twig templates:

It works out of the box with:

Enabling Storyblok’s Live Editor

This integration lets the Storyblok Visual Editor highlight components directly on your frontend and open the corresponding editing form automatically. Here’s how to set it up:

  1. Load the Storyblok bridge script

[!IMPORTANT] The javascript bridge is only loaded when the parameter storyblok.version is set to draft.

In your base.html.twig layout, include the Storyblok JavaScript bridge:

This script is responsible for detecting editable components on the page and opening the Live Editor when clicked.

  1. Make your block classes “editable”

Every block you want editable in the Live Editor must implement the EditableInterface and use the EditableTrait, allowing them to receive Storyblok’s _editable metadata:

[!TIP] Consider using the ValueObjectTrait included in this bundle to streamline the handling of Storyblok API responses. Real-world content data is often inconsistent — keys may be missing, values may have unexpected formats, or fields might be empty. The helper methods in this trait handle these edge cases for you, allowing you to write clean, defensive, and readable code with minimal boilerplate.

Read more →

This setup ensures Storyblok provides the necessary metadata to each block instance.

  1. Render editable markers in your templates

Insert Storyblok attributes into your HTML elements using the Twig filter. These attributes tell the bridge where each editable block is located:

With this in place, components are “highlightable” in the Live Editor — clicking them opens the edit form seamlessly.

Helpers

The Storyblok\Bundle\Util\ValueObjectTrait provides utility methods for mapping raw Storyblok data arrays into strong PHP value objects, enums, and domain models. These helpers reduce boilerplate code and improve readability in DTO constructors or factory methods.

Use this trait in your value objects or models to simplify the parsing and validation of Storyblok field values.

Available Methods

Method Description
Blocks() Resolves a list of blocks using the BlockRegistry. Returns instances of block classes. Ignores unknown blocks.

For a full list of available methods see this Documentation

License

This project is licensed under the MIT License. Please see License File for more information.


All versions of symfony-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
oskarstark/enum-helper Version ^1.6
psr/log Version ^3.0
storyblok/php-content-api-client Version >=1.9.0
storyblok/php-tiptap-extension Version ^1.0
symfony/config Version ^6.0 || ^7.0
symfony/dependency-injection Version ^6.0 || ^7.0
symfony/framework-bundle Version ^6.0 || ^7.0
symfony/http-client Version ^6.0 || ^7.0
symfony/http-kernel Version ^6.0 || ^7.0
symfony/monolog-bundle Version ^3.10
symfony/string Version ^6.0 || ^7.0
thecodingmachine/safe Version ^2.0 || ^3.0
twig/twig Version ^3.20
webmozart/assert Version ^1.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package storyblok/symfony-bundle contains the following files

Loading the files please wait ....