PHP code example of yiisoft / yii2-redis

1. Go to this page and download the library: Download yiisoft/yii2-redis 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/ */

    

yiisoft / yii2-redis example snippets


return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];

return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6380,
            'database' => 0,
            'useSSL' => true,
            // Use contextOptions for more control over the connection (https://www.php.net/manual/en/context.php), not usually needed
            'contextOptions' => [
                'ssl' => [
                    'local_cert' => '/path/to/local/certificate',
                    'local_pk' => '/path/to/local/private_key',
                ],
            ],
        ],
    ],
];

return [
    //....
    'components' => [
        'redis' => [
            //....
            'scheme' => 'tls'
        ]
    ]
];

php composer.phar