PHPackages                             fusionauth/fusionauth-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. fusionauth/fusionauth-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

fusionauth/fusionauth-client
============================

FusionAuth Client written in PHP

1.64.0(2mo ago)22964.8k—7.4%13[8 issues](https://github.com/FusionAuth/fusionauth-php-client/issues)1Apache-2.0PHPCI passing

Since Sep 11Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/FusionAuth/fusionauth-php-client)[ Packagist](https://packagist.org/packages/fusionauth/fusionauth-client)[ Docs](https://github.com/FusionAuth/fusionauth-php-client)[ RSS](/packages/fusionauth-fusionauth-client/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (305)Used By (1)

FusionAuth PHP Client [![semver 2.0.0 compliant](https://camo.githubusercontent.com/d7b953e106bfad43e75036f6b53e1ff5581d61f2d039174eddb8c126df216010/687474703a2f2f696d672e736869656c64732e696f2f62616467652f73656d7665722d322e302e302d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/d7b953e106bfad43e75036f6b53e1ff5581d61f2d039174eddb8c126df216010/687474703a2f2f696d672e736869656c64732e696f2f62616467652f73656d7665722d322e302e302d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#fusionauth-php-client-)

Intro
-----

[](#intro)

If you're integrating FusionAuth with a PHP application, this library will speed up your development time. Please also make sure to check our [SDK Usage Suggestions page](https://fusionauth.io/docs/sdks/#usage-suggestions).

For additional information and documentation on FusionAuth refer to .

Install
-------

[](#install)

The most preferred way to use the client library is to install the [`fusionauth/fusionauth-client`](https://packagist.org/packages/fusionauth/fusionauth-client) package via Composer by running the command below at your project root folder.

```
composer require fusionauth/fusionauth-client
```

Then, include the `composer` autoloader in your PHP files.

```
require __DIR__ . '/vendor/autoload.php';
```

Examples
--------

[](#examples)

### Set Up

[](#set-up)

First, you have to make sure you have a running FusionAuth instance. If you don't have one already, the easiest way to install FusionAuth is [via Docker](https://fusionauth.io/docs/get-started/download-and-install/docker), but there are [other ways](https://fusionauth.io/docs/get-started/download-and-install). By default, it'll be running on `localhost:9011`.

Then, you have to [create an API Key](https://fusionauth.io/docs/apis/authentication#managing-api-keys) in the admin UI to allow calling API endpoints.

You are now ready to use this library!

### Error Handling

[](#error-handling)

After every request is made, you need to check for any errors and handle them. To avoid cluttering things up, we'll omit the error handling in the next examples, but you should do something like the following.

```
// $result is the response of one of the endpoint invocations from the examples below

if (!$result->wasSuccessful()) {
    echo "Error!" . PHP_EOL;
    echo "Got HTTP {$result->status}" . PHP_EOL;
    if (isset($result->errorResponse->fieldErrors)) {
        echo "There are some errors with the payload:" . PHP_EOL;
        var_dump($result->errorResponse->fieldErrors);
    }
    if (isset($result->errorResponse->generalErrors)) {
        echo "There are some general errors:" . PHP_EOL;
        var_dump($result->errorResponse->generalErrors);
    }
}
```

### Create the Client

[](#create-the-client)

To make requests to the API, first you need to create a `FusionAuthClient` instance with [the API Key created](https://fusionauth.io/docs/apis/authentication#managing-api-keys) and the server address where FusionAuth is running.

```
$client = new FusionAuth\FusionAuthClient(
    apiKey: "",
    baseURL: "http://localhost:9011", // or change this to whatever address FusionAuth is running on
);
```

### Create an Application

[](#create-an-application)

To create an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use the `createApplication()` method.

```
$result = $client->createApplication(
    applicationId: null, // Leave this empty to automatically generate the UUID
    request: [
        'application' => [
            'name' => 'ChangeBank',
        ],
    ],
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
var_dump($result->successResponse->application);
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application)

### Adding Roles to an Existing Application

[](#adding-roles-to-an-existing-application)

To add [roles to an Application](https://fusionauth.io/docs/get-started/core-concepts/applications#roles), use `createApplicationRole()`.

```
$result = $client->createApplicationRole(
    applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', // Existing Application Id
    roleId: null, // Leave this empty to automatically generate the UUID
    request: [
        'role' => [
            'name' => 'customer',
            'description' => 'Default role for regular customers',
            'isDefault' => true,
        ],
    ],
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
var_dump($result->successResponse->role);
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application-role)

### Retrieve Application Details

[](#retrieve-application-details)

To fetch details about an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `retrieveApplication()`.

```
$result = $client->retrieveApplication(
    applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc',
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
var_dump($result->successResponse->application);
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#retrieve-an-application)

### Delete an Application

[](#delete-an-application)

To delete an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `deleteApplication()`.

```
$result = $client->deleteApplication(
    applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc',
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
// Note that $result->successResponse will be empty
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#delete-an-application)

### Lock a User

[](#lock-a-user)

To [prevent a User from logging in](https://fusionauth.io/docs/get-started/core-concepts/users), use `deactivateUser()`.

```
$result = $client->deactivateUser(
    'fa0bc822-793e-45ee-a7f4-04bfb6a28199',
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/users#delete-a-user)

### Registering a User

[](#registering-a-user)

To [register a User in an Application](https://fusionauth.io/docs/get-started/core-concepts/users#registrations), use `register()`.

The code below also adds a `customer` role and a custom `appBackgroundColor` property to the User Registration.

```
$result = $client->register(
    userId: 'fa0bc822-793e-45ee-a7f4-04bfb6a28199',
    request: [
        'registration' => [
            'applicationId' => 'd564255e-f767-466b-860d-6dcb63afe4cc',
            'roles' => [
                'customer',
            ],
            'data' => [
                'appBackgroundColor' => '#096324',
            ],
        ],
    ],
);

// Handle errors as shown in the beginning of the Examples section

// Otherwise parse the successful response
```

[Check the API docs for this endpoint](https://fusionauth.io/docs/apis/registrations#create-a-user-registration-for-an-existing-user)

Questions and support
---------------------

[](#questions-and-support)

If you find any bugs in this library, [please open an issue](https://github.com/FusionAuth/fusionauth-php-client/issues). Note that changes to the `FusionAuthClient` class have to be done on the [FusionAuth Client Builder repository](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/php.client.ftl), which is responsible for generating that file.

But if you have a question or support issue, we'd love to hear from you.

If you have a paid plan with support included, please [open a ticket in your account portal](https://account.fusionauth.io/account/support/). Learn more about [paid plan here](https://fusionauth.io/pricing).

Otherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/).

Contributing
------------

[](#contributing)

Bug reports and pull requests are welcome on GitHub at .

Note: if you want to change the `FusionAuthClient` class, you have to do it on the [FusionAuth Client Builder repository](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/php.client.ftl), which is responsible for generating all client libraries we support.

License
-------

[](#license)

This code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/blog/license/apache-2-0).

Upgrade Policy
--------------

[](#upgrade-policy)

This library is built automatically to keep track of the FusionAuth API, and may also receive updates with bug fixes, security patches, tests, code samples, or documentation changes.

These releases may also update dependencies, language engines, and operating systems, as we'll follow the deprecation and sunsetting policies of the underlying technologies that it uses.

This means that after a dependency (e.g. language, framework, or operating system) is deprecated by its maintainer, this library will also be deprecated by us, and will eventually be updated to use a newer version.

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance82

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 71.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~25 days

Total

181

Last Release

63d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aae080ddecf6e5344e9e40c3b15e90af25721cc99794de5c4fd12ca88e187f7c?d=identicon)[robotdan](/maintainers/robotdan)

![](https://www.gravatar.com/avatar/9b15b07b3cc8c22659ac3f6f663a0dd9ce82f6729166372140d8322511ede0ad?d=identicon)[mooreds](/maintainers/mooreds)

![](https://www.gravatar.com/avatar/c0941e1f1dee735fa55cf5ef8d5eda6ba85807065e8ec18df77974f4afdb40fa?d=identicon)[fusionauth-platform](/maintainers/fusionauth-platform)

---

Top Contributors

[![robotdan](https://avatars.githubusercontent.com/u/1148709?v=4)](https://github.com/robotdan "robotdan (245 commits)")[![wied03](https://avatars.githubusercontent.com/u/297123?v=4)](https://github.com/wied03 "wied03 (20 commits)")[![lyleschemmerling](https://avatars.githubusercontent.com/u/11809481?v=4)](https://github.com/lyleschemmerling "lyleschemmerling (18 commits)")[![vcampitelli](https://avatars.githubusercontent.com/u/1877191?v=4)](https://github.com/vcampitelli "vcampitelli (14 commits)")[![johnjeffers](https://avatars.githubusercontent.com/u/11821214?v=4)](https://github.com/johnjeffers "johnjeffers (11 commits)")[![matthew-altman](https://avatars.githubusercontent.com/u/55401860?v=4)](https://github.com/matthew-altman "matthew-altman (8 commits)")[![voidmain](https://avatars.githubusercontent.com/u/377102?v=4)](https://github.com/voidmain "voidmain (5 commits)")[![appsec-tpc](https://avatars.githubusercontent.com/u/252938511?v=4)](https://github.com/appsec-tpc "appsec-tpc (3 commits)")[![flangfeldt](https://avatars.githubusercontent.com/u/1012764?v=4)](https://github.com/flangfeldt "flangfeldt (3 commits)")[![mooreds](https://avatars.githubusercontent.com/u/91825?v=4)](https://github.com/mooreds "mooreds (3 commits)")[![spwitt](https://avatars.githubusercontent.com/u/3409780?v=4)](https://github.com/spwitt "spwitt (3 commits)")[![mmanes](https://avatars.githubusercontent.com/u/7048740?v=4)](https://github.com/mmanes "mmanes (2 commits)")[![bhalsey](https://avatars.githubusercontent.com/u/211656?v=4)](https://github.com/bhalsey "bhalsey (2 commits)")[![JuliusPC](https://avatars.githubusercontent.com/u/15018932?v=4)](https://github.com/JuliusPC "JuliusPC (2 commits)")[![TanguyGiton](https://avatars.githubusercontent.com/u/16117761?v=4)](https://github.com/TanguyGiton "TanguyGiton (1 commits)")[![fusionauth-platform-team](https://avatars.githubusercontent.com/u/158609934?v=4)](https://github.com/fusionauth-platform-team "fusionauth-platform-team (1 commits)")[![robfusion](https://avatars.githubusercontent.com/u/90628992?v=4)](https://github.com/robfusion "robfusion (1 commits)")

---

Tags

api-clientfusionauthfusionauth-clientphpphp-clientrest-clientapirestfusionauth

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fusionauth-fusionauth-client/health.svg)

```
[![Health](https://phpackages.com/badges/fusionauth-fusionauth-client/health.svg)](https://phpackages.com/packages/fusionauth-fusionauth-client)
```

###  Alternatives

[xendit/xendit-php

Xendit PHP SDK

189730.6k6](/packages/xendit-xendit-php)[angelleye/paypal-php-library

PHP wrapper for PayPal APIs

243440.9k](/packages/angelleye-paypal-php-library)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[mediamonks/rest-api-bundle

MediaMonks Rest API Symfony Bundle

1656.2k1](/packages/mediamonks-rest-api-bundle)[phrest/api

REST API Package for Phalcon PHP

304.2k](/packages/phrest-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
