1. Go to this page and download the library: Download casdoor/casdoor-php-sdk 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/ */
casdoor / casdoor-php-sdk example snippets
namespace Casdoor\Tests;
use PHPUnit\Framework\TestCase;
use Casdoor\Auth\Jwt;
use Casdoor\Auth\Token;
use Casdoor\Auth\User;
class OauthTest extends TestCase
{
public function xxx(){}
}
public $code = "cc78dc9953ca6ae6ab58";
public $state = "casdoor";
public function testGetOauthToken()
{
$this->initConfig();
$token = new Token();
$accessToken = $token->getOAuthToken($this->code, $this->state);
$this->assertIsString($accessToken->getToken());
}
public function testParseJwtToken()
{
$this->initConfig();
$token = "eyJhxxxx"; // from testGetOauthToken()
$jwt = new Jwt();
$result = $jwt->parseJwtToken($token, User::$authConfig);
$this->assertIsArray();
}
public function testModifyUser()
{
$this->initConfig();
$user = new User();
# Delete User
$user->name = 'user_hn99qa';
$response = $user->deleteUser($user);
$this->assertTrue($response);
# Add User
$response = $user->addUser($user);
$this->assertTrue($response);
# Update User
$user->phone = 'phone';
$user->displayName = 'display name';
$response = $user->updateUser($user);
$this->assertTrue($response);
}
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.