Works with any PHP framework
The client is a plain PHP library with zero framework dependencies — drop it into Laravel, Yii, CodeIgniter, Symfony, or a standalone script.
Plain PHP
Laravel
Yii
CodeIgniterEverything in the token lifecycle
Fluent, chainable API covering authentication, registration, and the full token lifecycle.
Exchange credentials for a JWT
Authenticate any WordPress user by email or username and receive a signed JWT. Pass the token in the Authorization header for all subsequent requests to protected endpoints.
Packagist →// Authenticate a user and get a JWT $client = new SimpleJwtLoginClient($siteUrl, $authCode); $response = $client ->withEmail('user@example.com') ->withPassword('secret') ->authenticate(); // $response['data']['jwt'] contains your token $jwt = $response['data']['jwt']; echo 'Token: ' . $jwt;
Built for real PHP workflows
From headless WordPress to automated testing — the client handles the auth layer so you can focus on your app.
Headless WordPress
Build a decoupled frontend in Laravel, Symfony, or plain PHP while WordPress handles content. Authenticate users from your PHP app and pass JWTs to the WP REST API.
$client = new SimpleJwtLoginClient($wpUrl, $authCode);
// Log the user in from your PHP frontend
$auth = $client
->withEmail($request->email)
->withPassword($request->password)
->authenticate();
$jwt = $auth['data']['jwt'];
// Now call any WP REST endpoint with the token
$posts = Http::withToken($jwt)
->get($wpUrl . '/wp-json/wp/v2/posts')
->json();User registration flow
Register users from your own sign-up form and immediately issue a JWT — all in one round trip, without touching the WordPress admin.
$client = new SimpleJwtLoginClient($wpUrl, $authCode);
$response = $client
->withEmail($data['email'])
->withPassword($data['password'])
->withExtraParameter('first_name', $data['name'])
->register();
// Immediately authenticate the new user
$auth = $client
->withEmail($data['email'])
->withPassword($data['password'])
->authenticate();
$jwt = $auth['data']['jwt'];Automated testing
Generate tokens in PHPUnit or Pest fixtures to test authenticated flows against a real WordPress instance — no browser, no cookies, no mocking.
// In your PHPUnit setUp()
protected function setUp(): void
{
$client = new SimpleJwtLoginClient(
getenv('WP_URL'),
getenv('SJL_AUTH_CODE')
);
$auth = $client
->withEmail(getenv('TEST_USER_EMAIL'))
->withPassword(getenv('TEST_USER_PASSWORD'))
->authenticate();
$this->jwt = $auth['data']['jwt'];
}Up and running in minutes
Requirements
- PHP5.5+
- Composerany
- Simple JWT Loginactive
- WordPress4.4+
Add the package to your project with a single command.
composer require "nicumicle/simple-jwt-login-client-php"
Pass your WordPress site URL and Simple JWT Login Auth Code.
use SimpleJwtLoginClient\SimpleJwtLoginClient; $client = new SimpleJwtLoginClient( 'https://your-wordpress-site.com', 'your-auth-code' );
Use the fluent interface to authenticate, register, or manage tokens.
$response = $client ->withEmail('user@example.com') ->withPassword('secret') ->authenticate(); $jwt = $response['data']['jwt'];
Complete method reference
All available client methods at a glance.
authenticate()Exchange credentials for a JWT tokenregister()Create a new WordPress user accountdeleteUser()Delete a user via a verified JWTvalidateToken()Verify a token signature and expiryrefreshToken()Get a new token from an expiring onerevokeToken()Permanently invalidate a tokenautologin()Generate a one-click auto-login URLchangePassword()Change the authenticated user's passwordresetPassword()Trigger a password reset emailAdd JWT to your PHP app today
One Composer install and a few lines of code — that's all it takes to add WordPress JWT authentication to any PHP project.