PHP code example of takethelead / laravel-storyblok

1. Go to this page and download the library: Download takethelead/laravel-storyblok library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

takethelead / laravel-storyblok example snippets




return [

    /**
     * The api key used to authenticated with the Storyblok api.
     */
    'api_key' => env('STORYBLOK_API_KEY'),

    /**
     * Cache Storyblok api responses.
     */
    'enable_local_cache' => env('STORYBLOK_ENABLE_LOCAL_CACHE', true),

    /**
     * Cache filename.
     */
    'cache_version_file_name' => 'storyblok-content-version.json',

    /**
     * Cache location on the selected disk
     */
    'cache_path' => 'storyblok/cache',

    /**
     * Storage disk
     */
    'disk' => 'local',

    /**
     * Enable edit mode.
     */
    'enable_edit_mode' => env('STORYBLOK_ENABLE_EDIT_MODE', false),

    /**
     * The webhook secret, you can leave this empty when you are not using a secret.
     */
    'webhook_secret' => env('STORYBLOK_WEBHOOK_SECRET', ''),

    /**
     * The middleware that should be applied to the webhook route.
     */
    'route_middleware' => [
        \TakeTheLead\LaravelStoryblok\Http\Middleware\VerifyStoryblokWebhookSignature::class,
    ],

    /**
     * The actions that should be execute whenever the webhook gets called.
     *
     * All actions should implement the \TakeTheLead\LaravelStoryblok\Actions\ActionInterface
     */
    'webhook_actions' => [
        \TakeTheLead\LaravelStoryblok\Actions\ClearCacheAction::class,
    ],
];

use Storyblok;

Storyblok::getStoryBySlug("story-slug");
Stroyblok::getStoryByUuid("story-uuid");

use Storyblok;

$api = Storyblok::getApi();

Route::storyblok();
bash
php artisan vendor:publish --provider="TakeTheLead\LaravelStoryblok\LaravelStoryblokServiceProvider" --tag="config"



use \TakeTheLead\LaravelStoryblok\Actions\ActionInterface;

class YourAction implements ActionInterface
{
    public function __construct()
    {
        // you can inject any class registerd within the IOC container
    }

    public function execute(): void
    {
        // Perform your action
    }
}
bash
php artisan storyblok:clear-cache