From 39f34af4f73b25e32632b13a30fe7f89f10a4372 Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Sun, 10 Mar 2024 15:22:40 +0800 Subject: [PATCH] Improve README --- README.md | 2 - README_zh-CN.md | 118 ------------------------------------------------ 2 files changed, 120 deletions(-) delete mode 100644 README_zh-CN.md diff --git a/README.md b/README.md index 9e96702..5394656 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ [![Latest Stable Version](http://poser.pugx.org/casdoor/casdoor-php-sdk/v)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![Total Downloads](http://poser.pugx.org/casdoor/casdoor-php-sdk/downloads)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![Latest Unstable Version](http://poser.pugx.org/casdoor/casdoor-php-sdk/v/unstable)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![License](http://poser.pugx.org/casdoor/casdoor-php-sdk/license)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![PHP Version Require](http://poser.pugx.org/casdoor/casdoor-php-sdk/require/php)](https://packagist.org/packages/casdoor/casdoor-php-sdk) -Chinese: [README_zh-CN.md](README_zh-CN.md) - Casdoor PHP SDK will allow you to easily connect your application to Casdoor authentication system without having to start from scratch. # Step 1: Composer install casdoor-php-sdk diff --git a/README_zh-CN.md b/README_zh-CN.md deleted file mode 100644 index 57de86c..0000000 --- a/README_zh-CN.md +++ /dev/null @@ -1,118 +0,0 @@ -# casdoor-php-sdk - -[![Latest Stable Version](http://poser.pugx.org/casdoor/casdoor-php-sdk/v)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![Total Downloads](http://poser.pugx.org/casdoor/casdoor-php-sdk/downloads)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![Latest Unstable Version](http://poser.pugx.org/casdoor/casdoor-php-sdk/v/unstable)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![License](http://poser.pugx.org/casdoor/casdoor-php-sdk/license)](https://packagist.org/packages/casdoor/casdoor-php-sdk) [![PHP Version Require](http://poser.pugx.org/casdoor/casdoor-php-sdk/require/php)](https://packagist.org/packages/casdoor/casdoor-php-sdk) - -# 描述 -Casdoor的PHP SDK将允许您轻松地将应用程序连接到Casdoor身份验证系统,而无需从头开始实现。 - -# 步骤一、Composer安装casdoor-php-sdk -在你的php应用目录下,执行以下命令: -``` -composer require casdoor/casdoor-php-sdk -``` -或者使用composer.json添加如下代码: -``` -{ - "require": { - "vendor/package": "*", - } -} -``` -然后执行composer install使其生效。 -同时创建一个OauthTest.php文件,并引入SDK包。 -```php -initConfig(); - $token = new Token(); - $accessToken = $token->getOAuthToken($this->code, $this->state); - $this->assertIsString($accessToken->getToken()); -} -``` -JWT令牌代表用户的身份,有权调用相关的API。 -# 步骤四:校验与解析用户令牌 -用户传入JWT令牌,testParseJwtToken函数会调用公钥对该JWT令牌进行校验。若校验通过,则返回Array对象,内含用户的账号信息。 -```php -public function testParseJwtToken() -{ - $this->initConfig(); - $token = "eyJhxxxx"; // from testGetOauthToken() - $jwt = new Jwt(); - $result = $jwt->parseJwtToken($token, User::$authConfig); - $this->assertIsArray(); -} -``` -# 步骤五:更新用户信息 -testModifyUser调用应用配置(非用户令牌)作为更新权限,对用户的信息做CURD操作。 -```php -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); -} -``` -# 其他:用户交互 - -- User::getUser() ,通过用户名来获取用户信息 -- User::getUsers(),获得所有用户的信息 -- User::getUserCount(),获得当前用户数量