3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * SIMPLE JWT TOKEN GENERATOR FOR C# API GATEWAY * * Quick setup: * 1. Run: composer install * 2. Update the $clientSecret variable below * 3. Run: php simple_jwt_example.php */ require_once 'vendor/autoload.php'; use Firebase\JWT\JWT; // ======================================== // CONFIGURATION (Match your Program.cs) // ======================================== $issuer = "https://abc.com/authservice"; $audience = "https://abc.com/megamart"; $clientSecret = "YOUR_SECRET_KEY_HERE"; // ⚠️ MUST MATCH Line 5 in Program.cs! // ======================================== // CREATE TOKEN // ======================================== $payload = [ 'iss' => $issuer, // Issuer 'aud' => $audience, // Audience 'iat' => time(), // Issued at 'nbf' => time(), // Not before 'exp' => time() + (60 * 60), // Expires in 1 hour // Custom claims (your user data) 'sub' => '12345', // User ID 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'role' => 'Admin' ]; $jwt = JWT::encode($payload, $clientSecret, 'HS256'); // ======================================== // OUTPUT // ======================================== echo "JWT Token Generated:\n"; echo "====================\n\n"; echo $jwt . "\n\n"; ?> <?php /** * SIMPLE JWT TOKEN GENERATOR FOR C# API GATEWAY * * Quick setup: * 1. Run: composer install * 2. Update the $clientSecret variable below * 3. Run: php simple_jwt_example.php */ require_once 'vendor/autoload.php'; use Firebase\JWT\JWT; // ======================================== // CONFIGURATION (Match your Program.cs) // ======================================== $issuer = "https://abc.com/authservice"; $audience = "https://abc.com/megamart"; $clientSecret = "YOUR_SECRET_KEY_HERE"; // ⚠️ MUST MATCH Line 5 in Program.cs! // ======================================== // CREATE TOKEN // ======================================== $payload = [ 'iss' => $issuer, // Issuer 'aud' => $audience, // Audience 'iat' => time(), // Issued at 'nbf' => time(), // Not before 'exp' => time() + (60 * 60), // Expires in 1 hour // Custom claims (your user data) 'sub' => '12345', // User ID 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'role' => 'Admin' ]; $jwt = JWT::encode($payload, $clientSecret, 'HS256'); // ======================================== // OUTPUT // ======================================== echo "JWT Token Generated:\n"; echo "====================\n\n"; echo $jwt . "\n\n"; ?>
Output for 8.5.0 - 8.5.1
Fatal error: Cannot use Firebase\JWT\JWT as JWT because the name is already in use in /in/jPQNE on line 62 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.1.34, 8.2.27 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.16
Fatal error: Cannot use Firebase\JWT\JWT as JWT because the name is already in use in /in/jPQNE on line 62
Process exited with code 255.

preferences:
164.41 ms | 1010 KiB | 7 Q