PHP code example of bingher / php-cas-client
1. Go to this page and download the library: Download bingher/php-cas-client 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/ */
bingher / php-cas-client example snippets
composer
namespace app\index\controller;
use bingher\phpcas\Cas;
use think\facade\Config;
class Test
{
/**
* http://www.tp.com/index/test/login
* 测试环境 测试账号test2 123456
*/
public function login()
{
$cas = new Cas(Config::get('cas.'));
$user = $cas->login();
//TODO you login logic
}
/**
* 退出登录
* @return [type] [description]
*/
public function logout()
{
$callbackUrl = 'http://www.tp.com'; //如果设置为空默认回调到网站首页
$cas = new Cas(Config::get('cas.'));
$cas->logout($callbackUrl);
}
}