我跑sudo composer require lcobucci/jwt
來安裝東西。在Laravel找不到類5
然後,我在我的文件的頂部添加use Lcobucci\JWT\Configuration;
然後,我開始使用示例代碼
$config = new Configuration(); // This object helps to simplify the creation of the dependencies
// instead of using "?:" on constructors.
$token = $config->createBuilder()
->issuedBy('https://login.uat.telenet.be/openid') // Configures the issuer (iss claim)
->canOnlyBeUsedBy('site') // Configures the audience (aud claim)
->identifiedBy('888254e8-f1e8-4956-86fa-a6c0f61a6421', true) // Configures the id (jti claim), replicating as a header item
->issuedAt(time()) // Configures the time that the token was issue (iat claim)
->canOnlyBeUsedAfter(time() + 60) // Configures the time that the token can be used (nbf claim)
->expiresAt(time() + 3600) // Configures the expiration time of the token (exp claim)
->with('uid', 1) // Configures a new claim, called "uid"
->getToken(); // Retrieves the generated token
$token->getHeaders(); // Retrieves the token headers
$token->getClaims(); // Retrieves the token claims
echo $token->getHeader('jti'); // will print "4f1g23a12aa"
echo $token->getClaim('iss'); // will print "http://example.com"
echo $token->getClaim('uid'); // will print "1"
echo $token; // The string representation of the object is a JWT string (pretty easy, right?)
我不斷收到此錯誤
類「Lcobucci \智威湯遜\配置'找不到
我該如何預防?
這裏是我的整個composer.json文件
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"illuminate/html": "^5.0",
"laracasts/utilities": "~2.0",
"barryvdh/laravel-debugbar": "^2.0",
"sammyk/laravel-facebook-sdk": "~3.0",
"doctrine/dbal": "^2.5",
"lcobucci/jwt": "^3.2"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"mcamara/laravel-localization": "1.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Helpers\\": "app/Helpers/"
},
"files": ["app/Helper.php"]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
你把它添加到作曲家的自動加載路徑中了嗎? – apokryfos
存儲庫沒有提到任何有關的信息。 ... :(= https://github.com/lcobucci/jwt – ihue
如何手動添加它?您可以詳細說明或發佈您的答案或建議 – ihue