PHP code example of satoken / webman

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

    

satoken / webman example snippets


return [
    // 核心配置
    'satoken' => [
        'tokenName'   => 'satoken',
        'timeout'     => 2592000,
        'isConcurrent'=> true,
        'isShare'     => true,
    ],
    // Redis 持久层(多进程环境必须)
    'satoken-redis' => [
        'keyPrefix'   => 'satoken:',
    ],
];

use SaToken\Stp\StpUtil;

// 登录
StpUtil::login(10001);

// 校验当前会话是否已登录
StpUtil::checkLogin();

// 获取当前登录账号 id
$id = StpUtil::getLoginId();
bash
php webman vendor:publish satoken/webman