PHP code example of jobverplanke / craftcms-components

1. Go to this page and download the library: Download jobverplanke/craftcms-components 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/ */

    

jobverplanke / craftcms-components example snippets


// .env
CRAFT_CACHE_DRIVER=database

// config/app.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Cache;

return [
    'components' => [
        'cache' => fn () => Cache::driver(App::env('CRAFT_CACHE_DRIVER')),
    ],
];

// .env
CRAFT_QUEUE_DRIVER=database

// config/app.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Queue;

return [
    'components' => [
        'queue' => Queue::driver(App::env('CRAFT_QUEUE_DRIVER')),
    ],
];

// .env
CRAFT_SESSION_DRIVER=database

// config/app.web.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Session;

return [
    'components' => [
        'session' => fn () => Session::driver(App::env('CRAFT_SESSION_DRIVER')),
    ],
];

// config/app.php

use Verplanke\CraftComponents\Components\Redis;

return [
    'components' => [
        'redis' => Redis::connect(),
    ],
];

// .env
CRAFT_CACHE_DRIVER=redis

// config/app.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Cache;

return [
    'components' => [
        'cache' => fn () => Cache::driver(App::env('CRAFT_CACHE_DRIVER')),
    ],
];

// .env
CRAFT_QUEUE_DRIVER=redis

// config/app.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Queue;

return [
    'components' => [
        'queue' => Queue::driver(App::env('CRAFT_QUEUE_DRIVER')),
    ],
];

// .env
CRAFT_SESSION_DRIVER=redis

// config/app.web.php

use craft\helpers\App;
use Verplanke\CraftComponents\Components\Session;

return [
    'components' => [
        'session' => fn () => Session::driver(App::env('CRAFT_SESSION_DRIVER')),
    ],
];