enygma / stormpath
此包已被弃用且不再维护。未建议替代包。
PHP 库,用于与 Stormpath 用户身份验证 API 接口
dev-master
2013-04-28 19:37 UTC
Requires
- php: >=5.3.1
- guzzle/guzzle: 3.0.*@dev
This package is auto-updated.
Last update: 2022-02-01 12:24:42 UTC
README
此库是使用 Stormpath 用户身份验证 REST API 的示例。它是一个功能有限的证明概念,主要围绕他们的“应用程序”概念定义。
示例使用
您需要在与您的测试脚本相同的目录下拥有他们提供的apiKey.properties
文件 - 它会在那里寻找。
示例代码
<?php require_once 'vendor/autoload.php'; // Define a configuration object with your tenant ID $config = new \Stormpath\Config(); $config->set('tenantId', 'sample-tenant-id-here'); // Create a service instance $service = new \Stormpath\Service($config); // You can use "magic properties" to get the application list $apps = $service->applications; // Or you can fetch the info for just one on the list $appId = 'your-application-id-here'; $app = $service->getApplication($appId); echo 'App name: '.$app->name." (".$app->status.")\n"; // You can also update the application... $app->name = 'test6'; $service->save($app); // ...or make a new one $newApp = new \Stormpath\Application(); $newApp->name = 'test4'; $newApp->description = 'test1 desc'; $newApp->status = 'enabled'; $service->save($newApp); // There's two functions to enable and disable the application too if ($app->disable() == true) { echo 'Application disabled!'; } if ($app->enable() == true) { echo 'Application enabled!'; } ?>
运行测试
要为此库运行单元测试,使用 PHPUnit 如下:
phpunit -c tests/phpunit.xml tests/