A Storyblok boilerplate in php with silex to kickstart your website.
If you want to use your server or have already an existing project in which you want to integrate Storyblok you can use one of the Storyblok boilerplates.
The most efficient way to start a Storyblok project as a developer would be with the Command Line Interface.
npm i storyblok -g
storyblok
and choose your boilerplate. You can of course simply download
or clone
this repository as well.
git clone https://github.com/storyblok/silex-boilerplate
In the webapp/config.php
all you need to change is the STORYBLOK_CONFIGURATION
- by adding your space information. What is a Space?:
$app['config.home'] = 'home'; #change this to your home story slug
$app['storyblok.privateToken'] = 'Iw3XKcJb6MwkdZEwoQ9BCQtt'; #change this to your private key.
Make sure Composer and npm are installed:
## Install PHP dependencies.
composer install
## Install all frontend development related dependencies.
npm install
## This will start up a php server on :4040 and a proxy for browsersync on :4200.
gulp
/app/
The place where you should put all your scripts, styles source code - you can also add your images here but make sure to add a gulp task which copies that to thepublic
folder./webapp/
The php application using silex and our client library./webapp/views/
All your layouts and components at one space - if you add a new or change an existing Twig component (.twig
) the gulp build will trigger an instant reload for you in the browser - also each component is a representation of a storyblok component. If you create a headline component in storyblok - make sure to create aheadline.twig
as well - so this application knows which component to render./public/
Once you rungulp
theapp
source files will be prepared (prefixed, minified, uglified, ...) and copied to the/public/
folder for delivery./cache/
Our client library directly adds a file cache (you can change this setting as well) for every storyblok request you do - this folder is the place where we save the cached results.
php -r "readfile('https://getcomposer.org/installer');" | php
sudo mkdir /usr/local/bin/
sudo mv composer.phar /usr/local/bin/composer