FusionAuth PHP Client
PHP Client Library
The PHP client library allows you to integrate FusionAuth with your PHP application.
Source code:
Install the library
To use the client library on your project simply copy the PHP source files from the src
directory to your project or the following
Composer package.
Packagist
composer require fusionauth/fusionauth-client
Include composer autoloader
require __DIR__ . '/vendor/autoload.php';
Create the Client
The following code assumes FusionAuth is running on http://localhost:9011
and uses an API key 5a826da2-1e3a-49df-85ba-cd88575e4e9d
, you will need to supply your own API key, and if you are not running FusionAuth locally, your host parameter may be different.
$apiKey = "5a826da2-1e3a-49df-85ba-cd88575e4e9d";
$client = new FusionAuth\FusionAuthClient($apiKey, "http://localhost:9011");
Login a user
$applicationId = "68364852-7a38-4e15-8c48-394eceafa601";
$request = array();
$request["applicationId"] = $applicationId;
$request["loginId"] = "joe@fusionauth.io";
$request["password"] = "abc123";
$result = $client->login($request);
if (!$result->wasSuccessful()) {
// Error
}
// Hooray! Success
Related Posts
Example apps
- Laravel - Protecting Laravel pages with FusionAuth
- Php jwt - JWT creation and decoding examples with the PHP firebase-jwt library
- Php multi-tenant - A Pied Piper multi-tenant video chat application
- Updating a legacy php app - Updating a legacy PHP app to OAuth and migrating users
- Webhooks - Handling a breached password detection webhook with PHP
Other PHP Libraries
Here are other PHP libraries that may be useful. Some are community supported; please visit the library website to learn more.