├── .github ├── CODEOWNERS ├── dependabot.yml ├── fusionauth │ ├── .env │ ├── docker-compose.yml │ └── kickstart.json └── workflows │ ├── deploy.yaml │ ├── docs.yaml │ └── test.yaml ├── .gitignore ├── .phpdoc └── template │ └── css │ └── custom.css.twig ├── LICENSE ├── README.md ├── build.savant ├── composer.json ├── composer.lock ├── docs ├── classes │ ├── FusionAuth-BodyHandler.html │ ├── FusionAuth-ClientResponse.html │ ├── FusionAuth-FormDataBodyHandler.html │ ├── FusionAuth-FusionAuthClient.html │ ├── FusionAuth-JSONBodyHandler.html │ ├── FusionAuth-JSONResponseHandler.html │ ├── FusionAuth-RESTClient.html │ ├── FusionAuth-ResponseHandler.html │ └── Tests-FusionAuthClientTest.html ├── css │ ├── base.css │ ├── normalize.css │ └── template.css ├── files │ ├── src-fusionauth-clientresponse.html │ ├── src-fusionauth-fusionauthclient.html │ ├── src-fusionauth-restclient.html │ └── tests-fusionauth-fusionauthclienttest.html ├── graphs │ └── classes.html ├── index.html ├── indices │ └── files.html ├── js │ ├── search.js │ ├── searchIndex.js │ └── template.js ├── namespaces │ ├── default.html │ ├── fusionauth.html │ └── tests.html ├── packages │ ├── Application.html │ └── default.html └── reports │ ├── deprecated.html │ ├── errors.html │ └── markers.html ├── fusionauth-php-client.iml ├── phpdoc.xml ├── phpunit.xml ├── src └── FusionAuth │ ├── ClientResponse.php │ ├── FusionAuthClient.php │ └── RESTClient.php └── tests └── FusionAuth └── FusionAuthClientTest.php /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a managed file. Manual changes will be overwritten. 2 | # https://github.com/FusionAuth/fusionauth-public-repos/ 3 | 4 | .github/ @fusionauth/owners @fusionauth/platform 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "docker" 4 | directory: "/.github/fusionauth" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/fusionauth/.env: -------------------------------------------------------------------------------- 1 | DATABASE_USERNAME=fusionauth 2 | DATABASE_PASSWORD=hkaLBM3RVnyYeYeqE3WI1w2e4Avpy0Wd5O3s3 3 | FUSIONAUTH_APP_MEMORY=256M 4 | FUSIONAUTH_APP_RUNTIME_MODE=development 5 | POSTGRES_USER=postgres 6 | POSTGRES_PASSWORD=postgres 7 | -------------------------------------------------------------------------------- /.github/fusionauth/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | db: 5 | image: postgres:16.0-alpine 6 | environment: 7 | PGDATA: /var/lib/postgresql/data/pgdata 8 | POSTGRES_USER: ${POSTGRES_USER} 9 | POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} 10 | healthcheck: 11 | test: [ "CMD-SHELL", "pg_isready -U postgres" ] 12 | interval: 5s 13 | timeout: 5s 14 | retries: 5 15 | networks: 16 | - db_net 17 | restart: unless-stopped 18 | volumes: 19 | - db_data:/var/lib/postgresql/data 20 | 21 | fusionauth: 22 | image: fusionauth/fusionauth-app:latest 23 | depends_on: 24 | db: 25 | condition: service_healthy 26 | environment: 27 | DATABASE_URL: jdbc:postgresql://db:5432/fusionauth 28 | DATABASE_ROOT_USERNAME: ${POSTGRES_USER} 29 | DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD} 30 | DATABASE_USERNAME: ${DATABASE_USERNAME} 31 | DATABASE_PASSWORD: ${DATABASE_PASSWORD} 32 | FUSIONAUTH_APP_MEMORY: ${FUSIONAUTH_APP_MEMORY} 33 | FUSIONAUTH_APP_RUNTIME_MODE: ${FUSIONAUTH_APP_RUNTIME_MODE} 34 | FUSIONAUTH_APP_SILENT_MODE: true 35 | FUSIONAUTH_APP_URL: http://fusionauth:9011 36 | FUSIONAUTH_APP_KICKSTART_FILE: /usr/local/fusionauth/kickstart.json 37 | SEARCH_TYPE: database 38 | networks: 39 | - db_net 40 | restart: unless-stopped 41 | ports: 42 | - 9011:9011 43 | volumes: 44 | - fusionauth_config:/usr/local/fusionauth/config 45 | - ./kickstart.json:/usr/local/fusionauth/kickstart.json 46 | 47 | networks: 48 | db_net: 49 | driver: bridge 50 | 51 | volumes: 52 | db_data: 53 | fusionauth_config: 54 | -------------------------------------------------------------------------------- /.github/fusionauth/kickstart.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "applicationid": "e9fdb985-9173-4e01-9d73-ac2d60d1dc8e", 4 | "apiKey": "72a8c464b86c3c9098c33da73f471b8a0352f6e14087ddc3", 5 | "asymmetricKeyId": "#{UUID()}", 6 | "defaultTenantId": "d7d09513-a3f5-401c-9685-34ab6c552453", 7 | "adminEmail": "admin@example.com", 8 | "adminPassword": "password" 9 | }, 10 | "apiKeys": [ 11 | { 12 | "key": "#{apiKey}", 13 | "description": "Unrestricted API key" 14 | } 15 | ], 16 | "requests": [ 17 | { 18 | "method": "POST", 19 | "url": "/api/key/generate/#{asymmetricKeyId}", 20 | "tenantId": "#{defaultTenantId}", 21 | "body": { 22 | "key": { 23 | "algorithm": "RS256", 24 | "name": "For GitHub Actions", 25 | "length": 2048 26 | } 27 | } 28 | }, 29 | { 30 | "method": "POST", 31 | "url": "/api/user/registration", 32 | "body": { 33 | "user": { 34 | "email": "#{adminEmail}", 35 | "password": "#{adminPassword}" 36 | }, 37 | "registration": { 38 | "applicationId": "#{FUSIONAUTH_APPLICATION_ID}", 39 | "roles": [ 40 | "admin" 41 | ] 42 | } 43 | } 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Deploy 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | command: 8 | type: choice 9 | options: 10 | - publish # publish to packagist 11 | - release # release to svn 12 | 13 | permissions: 14 | contents: read 15 | id-token: write 16 | 17 | jobs: 18 | deploy: 19 | runs-on: ubuntu-latest 20 | defaults: 21 | run: 22 | shell: /usr/bin/bash -l -e -o pipefail {0} 23 | steps: 24 | - name: checkout 25 | uses: actions/checkout@v4 26 | 27 | - name: setup java 28 | uses: actions/setup-java@v4 29 | with: 30 | distribution: temurin 31 | java-version: 21 32 | java-package: jre 33 | 34 | - name: install savant 35 | run: | 36 | curl -O https://repository.savantbuild.org/org/savantbuild/savant-core/2.0.0/savant-2.0.0.tar.gz 37 | tar xzvf savant-2.0.0.tar.gz 38 | savant-2.0.0/bin/sb --version 39 | SAVANT_PATH=$(realpath -s "./savant-2.0.0/bin") 40 | echo "${SAVANT_PATH}" >> $GITHUB_PATH 41 | mkdir -p ~/.savant/plugins 42 | cat << EOF > ~/.savant/plugins/org.savantbuild.plugin.java.properties 43 | 21=${JAVA_HOME} 44 | EOF 45 | 46 | - name: set aws credentials 47 | uses: aws-actions/configure-aws-credentials@v4 48 | with: 49 | role-to-assume: arn:aws:iam::752443094709:role/gha-fusionauth-php-client 50 | role-session-name: aws-auth-action 51 | aws-region: us-west-2 52 | 53 | - name: get secret 54 | run: | 55 | while IFS=$'\t' read -r key value; do 56 | echo "::add-mask::${value}" 57 | echo "${key}=${value}" >> $GITHUB_ENV 58 | done < <(aws secretsmanager get-secret-value \ 59 | --region us-west-2 \ 60 | --secret-id platform/php-packagist \ 61 | --query SecretString \ 62 | --output text | \ 63 | jq -r 'to_entries[] | [.key, .value] | @tsv') 64 | 65 | - name: update savant properties file 66 | run: | 67 | echo "packagistUsername=${{ env.USERNAME }}" >> ~/.savant/config.properties 68 | echo "packagistAPIToken=${{ env.API_KEY }}" >> ~/.savant/config.properties 69 | 70 | - name: release to svn 71 | if: inputs.command == 'release' 72 | run: sb release 73 | 74 | - name: publish to packagist 75 | if: inputs.command == 'publish' 76 | run: sb publish 77 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | docs: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | steps: 15 | - uses: actions/checkout@v4 16 | 17 | - name: Generate docs 18 | uses: phpDocumentor/phpDocumentor@master 19 | 20 | - uses: EndBug/add-and-commit@v9 21 | with: 22 | add: 'docs' 23 | message: ':memo: Updating docs' 24 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | permissions: 13 | contents: read 14 | 15 | jobs: 16 | test: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Set up FusionAuth 22 | working-directory: .github/fusionauth 23 | run: docker compose up -d 24 | 25 | - name: Validate composer.json and composer.lock 26 | run: | 27 | composer update 28 | composer validate 29 | 30 | - name: Cache Composer packages 31 | id: composer-cache 32 | uses: actions/cache@v4 33 | with: 34 | path: vendor 35 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 36 | restore-keys: | 37 | ${{ runner.os }}-php- 38 | 39 | - name: Install dependencies 40 | run: composer install --prefer-dist --no-progress 41 | 42 | - name: Waiting for FusionAuth App 43 | run: timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9011)" != "200" ]]; do sleep 5; done' || false 44 | 45 | - name: Run test suite 46 | run: composer run test 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iws 2 | **/.DS_Store 3 | /vendor 4 | .savant/cache 5 | .phpunit.cache 6 | .phpdoc/cache 7 | -------------------------------------------------------------------------------- /.phpdoc/template/css/custom.css.twig: -------------------------------------------------------------------------------- 1 | .phpdocumentor-title__link { 2 | margin-right: 1em; 3 | white-space: break-spaces; 4 | } 5 | .phpdocumentor-title__link:hover { 6 | transform: none; 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FusionAuth PHP Client ![semver 2.0.0 compliant](http://img.shields.io/badge/semver-2.0.0-brightgreen.svg?style=flat-square) 2 | 3 | ## Intro 4 | 5 | 8 | 9 | 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). 10 | 11 | For additional information and documentation on FusionAuth refer to [https://fusionauth.io](https://fusionauth.io). 12 | 13 | ## Install 14 | 15 | 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. 16 | 17 | ```bash 18 | composer require fusionauth/fusionauth-client 19 | ``` 20 | 21 | Then, include the `composer` autoloader in your PHP files. 22 | 23 | ```php 24 | require __DIR__ . '/vendor/autoload.php'; 25 | ``` 26 | 27 | ## Examples 28 | 29 | ### Set Up 30 | 31 | 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`. 32 | 33 | 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. 34 | 35 | You are now ready to use this library! 36 | 37 | ### Error Handling 38 | 39 | 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. 40 | 41 | ```php 42 | // $result is the response of one of the endpoint invocations from the examples below 43 | 44 | if (!$result->wasSuccessful()) { 45 | echo "Error!" . PHP_EOL; 46 | echo "Got HTTP {$result->status}" . PHP_EOL; 47 | if (isset($result->errorResponse->fieldErrors)) { 48 | echo "There are some errors with the payload:" . PHP_EOL; 49 | var_dump($result->errorResponse->fieldErrors); 50 | } 51 | if (isset($result->errorResponse->generalErrors)) { 52 | echo "There are some general errors:" . PHP_EOL; 53 | var_dump($result->errorResponse->generalErrors); 54 | } 55 | } 56 | ``` 57 | 58 | ### Create the Client 59 | 60 | 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. 61 | 62 | ```php 63 | $client = new FusionAuth\FusionAuthClient( 64 | apiKey: "", 65 | baseURL: "http://localhost:9011", // or change this to whatever address FusionAuth is running on 66 | ); 67 | ``` 68 | 69 | ### Create an Application 70 | 71 | To create an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use the `createApplication()` method. 72 | 73 | ```php 74 | $result = $client->createApplication( 75 | applicationId: null, // Leave this empty to automatically generate the UUID 76 | request: [ 77 | 'application' => [ 78 | 'name' => 'ChangeBank', 79 | ], 80 | ], 81 | ); 82 | 83 | // Handle errors as shown in the beginning of the Examples section 84 | 85 | // Otherwise parse the successful response 86 | var_dump($result->successResponse->application); 87 | ``` 88 | 89 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application) 90 | 91 | ### Adding Roles to an Existing Application 92 | 93 | To add [roles to an Application](https://fusionauth.io/docs/get-started/core-concepts/applications#roles), use `createApplicationRole()`. 94 | 95 | ```php 96 | $result = $client->createApplicationRole( 97 | applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', // Existing Application Id 98 | roleId: null, // Leave this empty to automatically generate the UUID 99 | request: [ 100 | 'role' => [ 101 | 'name' => 'customer', 102 | 'description' => 'Default role for regular customers', 103 | 'isDefault' => true, 104 | ], 105 | ], 106 | ); 107 | 108 | // Handle errors as shown in the beginning of the Examples section 109 | 110 | // Otherwise parse the successful response 111 | var_dump($result->successResponse->role); 112 | ``` 113 | 114 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#create-an-application-role) 115 | 116 | ### Retrieve Application Details 117 | 118 | To fetch details about an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `retrieveApplication()`. 119 | 120 | ```php 121 | $result = $client->retrieveApplication( 122 | applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', 123 | ); 124 | 125 | // Handle errors as shown in the beginning of the Examples section 126 | 127 | // Otherwise parse the successful response 128 | var_dump($result->successResponse->application); 129 | ``` 130 | 131 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#retrieve-an-application) 132 | 133 | ### Delete an Application 134 | 135 | To delete an [Application](https://fusionauth.io/docs/get-started/core-concepts/applications), use `deleteApplication()`. 136 | 137 | ```php 138 | $result = $client->deleteApplication( 139 | applicationId: 'd564255e-f767-466b-860d-6dcb63afe4cc', 140 | ); 141 | 142 | // Handle errors as shown in the beginning of the Examples section 143 | 144 | // Otherwise parse the successful response 145 | // Note that $result->successResponse will be empty 146 | ``` 147 | 148 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/applications#delete-an-application) 149 | 150 | ### Lock a User 151 | 152 | To [prevent a User from logging in](https://fusionauth.io/docs/get-started/core-concepts/users), use `deactivateUser()`. 153 | 154 | ```php 155 | $result = $client->deactivateUser( 156 | 'fa0bc822-793e-45ee-a7f4-04bfb6a28199', 157 | ); 158 | 159 | // Handle errors as shown in the beginning of the Examples section 160 | 161 | // Otherwise parse the successful response 162 | ``` 163 | 164 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/users#delete-a-user) 165 | 166 | ### Registering a User 167 | 168 | To [register a User in an Application](https://fusionauth.io/docs/get-started/core-concepts/users#registrations), use `register()`. 169 | 170 | The code below also adds a `customer` role and a custom `appBackgroundColor` property to the User Registration. 171 | 172 | ```php 173 | $result = $client->register( 174 | userId: 'fa0bc822-793e-45ee-a7f4-04bfb6a28199', 175 | request: [ 176 | 'registration' => [ 177 | 'applicationId' => 'd564255e-f767-466b-860d-6dcb63afe4cc', 178 | 'roles' => [ 179 | 'customer', 180 | ], 181 | 'data' => [ 182 | 'appBackgroundColor' => '#096324', 183 | ], 184 | ], 185 | ], 186 | ); 187 | 188 | // Handle errors as shown in the beginning of the Examples section 189 | 190 | // Otherwise parse the successful response 191 | ``` 192 | 193 | [Check the API docs for this endpoint](https://fusionauth.io/docs/apis/registrations#create-a-user-registration-for-an-existing-user) 194 | 195 | 198 | 199 | ## Questions and support 200 | 201 | 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. 202 | 203 | But if you have a question or support issue, we'd love to hear from you. 204 | 205 | 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). 206 | 207 | Otherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/). 208 | 209 | ## Contributing 210 | 211 | Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-php-client. 212 | 213 | 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. 214 | 215 | ## License 216 | 217 | This code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/blog/license/apache-2-0). 218 | 219 | 220 | ## Upgrade Policy 221 | 222 | 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. 223 | 224 | 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. 225 | 226 | 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. 227 | -------------------------------------------------------------------------------- /build.savant: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018-2024, FusionAuth, All Rights Reserved 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, 11 | * software distributed under the License is distributed on an 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 | * either express or implied. See the License for the specific 14 | * language governing permissions and limitations under the License. 15 | */ 16 | 17 | project(group: "io.fusionauth", name: "fusionauth-php-client", version: "1.58.0", licenses: ["ApacheV2_0"]) { 18 | workflow { 19 | fetch { 20 | cache() 21 | url(url: "https://repository.savantbuild.org") 22 | } 23 | publish { 24 | cache() 25 | } 26 | } 27 | 28 | publishWorkflow { 29 | subversion(repository: "https://svn.savantbuild.org") 30 | } 31 | } 32 | 33 | // Plugins 34 | file = loadPlugin(id: "org.savantbuild.plugin:file:2.0.0") 35 | idea = loadPlugin(id: "org.savantbuild.plugin:idea:2.0.0") 36 | release = loadPlugin(id: "org.savantbuild.plugin:release-git:2.0.0") 37 | 38 | target(name: "clean", description: "Cleans build directory") { 39 | file.prune(dir: "build") 40 | } 41 | 42 | target(name: "int", description: "Releases a local integration build of the project") { 43 | } 44 | 45 | target(name: "idea", description: "Updates the IntelliJ IDEA module file") { 46 | idea.iml() 47 | } 48 | 49 | target(name: "test", description: "Runs the tests", dependsOn: "clean") { 50 | runCommand("composer", "install") 51 | runCommand("vendor/bin/phpunit", "--include-path", "src", "-v", "tests") 52 | } 53 | 54 | target(name: "publish", description: "Update packagist to sync with our GitHub tags", dependsOn: ["clean", "int"]) { 55 | runCommand( 56 | "curl", "-XPOST", "-H", "Content-Type:application/json", 57 | "-d", "{\"repository\":{\"url\":\"https://packagist.org/packages/fusionauth/fusionauth-client\"}}", 58 | "https://packagist.org/api/update-package?username=${global.packagistUsername}&apiToken=${global.packagistAPIToken}" 59 | ) 60 | } 61 | 62 | target(name: "release", description: "Releases a full version of the project", dependsOn: ["int"]) { 63 | release.release() 64 | } 65 | 66 | def runCommand(String... args) { 67 | def process = new ProcessBuilder(args).inheritIO().directory(new File('.')).start() 68 | process.consumeProcessOutput(System.out, System.err) 69 | process.waitFor() 70 | if (process.exitValue() != 0) { 71 | fail("Unable to run command [${args.join(' ')}]") 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fusionauth/fusionauth-client", 3 | "type": "library", 4 | "description": "FusionAuth Client written in PHP", 5 | "keywords": ["rest","api", "fusionauth"], 6 | "homepage": "https://github.com/FusionAuth/fusionauth-php-client", 7 | "license": "Apache-2.0", 8 | "authors": [ 9 | { 10 | "name": "Daniel DeGroff", 11 | "email": "daniel@fuaionauth.io" 12 | }, 13 | { 14 | "name": "Brian Pontarelli", 15 | "email": "brian@fusionauth.io" 16 | } 17 | ], 18 | "require": { 19 | "ext-curl": "*", 20 | "ext-json": "*" 21 | }, 22 | "require-dev": { 23 | "phpunit/phpunit": "^10.5.8" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "FusionAuth\\": "src/FusionAuth/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Tests\\": "tests/FusionAuth/" 33 | } 34 | }, 35 | "scripts": { 36 | "test": "phpunit" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /docs/css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */ 2 | 3 | /** 4 | * 1. Set default font family to sans-serif. 5 | * 2. Prevent iOS text size adjust after orientation change, without disabling 6 | * user zoom. 7 | */ 8 | 9 | html { 10 | font-family: sans-serif; /* 1 */ 11 | -ms-text-size-adjust: 100%; /* 2 */ 12 | -webkit-text-size-adjust: 100%; /* 2 */ 13 | } 14 | 15 | /** 16 | * Remove default margin. 17 | */ 18 | 19 | body { 20 | margin: 0; 21 | } 22 | 23 | /* HTML5 display definitions 24 | ========================================================================== */ 25 | 26 | /** 27 | * Correct `block` display not defined for any HTML5 element in IE 8/9. 28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11 29 | * and Firefox. 30 | * Correct `block` display not defined for `main` in IE 11. 31 | */ 32 | 33 | article, 34 | aside, 35 | details, 36 | figcaption, 37 | figure, 38 | footer, 39 | header, 40 | hgroup, 41 | main, 42 | menu, 43 | nav, 44 | section, 45 | summary { 46 | display: block; 47 | } 48 | 49 | /** 50 | * 1. Correct `inline-block` display not defined in IE 8/9. 51 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. 52 | */ 53 | 54 | audio, 55 | canvas, 56 | progress, 57 | video { 58 | display: inline-block; /* 1 */ 59 | vertical-align: baseline; /* 2 */ 60 | } 61 | 62 | /** 63 | * Prevent modern browsers from displaying `audio` without controls. 64 | * Remove excess height in iOS 5 devices. 65 | */ 66 | 67 | audio:not([controls]) { 68 | display: none; 69 | height: 0; 70 | } 71 | 72 | /** 73 | * Address `[hidden]` styling not present in IE 8/9/10. 74 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. 75 | */ 76 | 77 | [hidden], 78 | template { 79 | display: none !important; 80 | } 81 | 82 | /* Links 83 | ========================================================================== */ 84 | 85 | /** 86 | * Remove the gray background color from active links in IE 10. 87 | */ 88 | 89 | a { 90 | background-color: transparent; 91 | } 92 | 93 | /** 94 | * Improve readability when focused and also mouse hovered in all browsers. 95 | */ 96 | 97 | a:active, 98 | a:hover { 99 | outline: 0; 100 | } 101 | 102 | /* Text-level semantics 103 | ========================================================================== */ 104 | 105 | /** 106 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome. 107 | */ 108 | 109 | abbr[title] { 110 | border-bottom: 1px dotted; 111 | } 112 | 113 | /** 114 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. 115 | */ 116 | 117 | b, 118 | strong { 119 | font-weight: bold; 120 | } 121 | 122 | /** 123 | * Address styling not present in Safari and Chrome. 124 | */ 125 | 126 | dfn { 127 | font-style: italic; 128 | } 129 | 130 | /** 131 | * Address variable `h1` font-size and margin within `section` and `article` 132 | * contexts in Firefox 4+, Safari, and Chrome. 133 | */ 134 | 135 | h1 { 136 | font-size: 2em; 137 | margin: 0.67em 0; 138 | } 139 | 140 | /** 141 | * Address styling not present in IE 8/9. 142 | */ 143 | 144 | mark { 145 | background: #ff0; 146 | color: #000; 147 | } 148 | 149 | /** 150 | * Address inconsistent and variable font size in all browsers. 151 | */ 152 | 153 | small { 154 | font-size: 80%; 155 | } 156 | 157 | /** 158 | * Prevent `sub` and `sup` affecting `line-height` in all browsers. 159 | */ 160 | 161 | sub, 162 | sup { 163 | font-size: 75%; 164 | line-height: 0; 165 | position: relative; 166 | vertical-align: baseline; 167 | } 168 | 169 | sup { 170 | top: -0.5em; 171 | } 172 | 173 | sub { 174 | bottom: -0.25em; 175 | } 176 | 177 | /* Embedded content 178 | ========================================================================== */ 179 | 180 | /** 181 | * Remove border when inside `a` element in IE 8/9/10. 182 | */ 183 | 184 | img { 185 | border: 0; 186 | } 187 | 188 | /** 189 | * Correct overflow not hidden in IE 9/10/11. 190 | */ 191 | 192 | svg:not(:root) { 193 | overflow: hidden; 194 | } 195 | 196 | /* Grouping content 197 | ========================================================================== */ 198 | 199 | /** 200 | * Address margin not present in IE 8/9 and Safari. 201 | */ 202 | 203 | figure { 204 | margin: 1em 40px; 205 | } 206 | 207 | /** 208 | * Address differences between Firefox and other browsers. 209 | */ 210 | 211 | hr { 212 | -moz-box-sizing: content-box; 213 | box-sizing: content-box; 214 | height: 0; 215 | } 216 | 217 | /** 218 | * Contain overflow in all browsers. 219 | */ 220 | 221 | pre { 222 | overflow: auto; 223 | } 224 | 225 | /** 226 | * Address odd `em`-unit font size rendering in all browsers. 227 | */ 228 | 229 | code, 230 | kbd, 231 | pre, 232 | samp { 233 | font-family: var(--font-monospace); 234 | font-size: 1em; 235 | } 236 | 237 | /* Forms 238 | ========================================================================== */ 239 | 240 | /** 241 | * Known limitation: by default, Chrome and Safari on OS X allow very limited 242 | * styling of `select`, unless a `border` property is set. 243 | */ 244 | 245 | /** 246 | * 1. Correct color not being inherited. 247 | * Known issue: affects color of disabled elements. 248 | * 2. Correct font properties not being inherited. 249 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. 250 | */ 251 | 252 | button, 253 | input, 254 | optgroup, 255 | select, 256 | textarea { 257 | color: inherit; /* 1 */ 258 | font: inherit; /* 2 */ 259 | margin: 0; /* 3 */ 260 | } 261 | 262 | /** 263 | * Address `overflow` set to `hidden` in IE 8/9/10/11. 264 | */ 265 | 266 | button { 267 | overflow: visible; 268 | } 269 | 270 | /** 271 | * Address inconsistent `text-transform` inheritance for `button` and `select`. 272 | * All other form control elements do not inherit `text-transform` values. 273 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. 274 | * Correct `select` style inheritance in Firefox. 275 | */ 276 | 277 | button, 278 | select { 279 | text-transform: none; 280 | } 281 | 282 | /** 283 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 284 | * and `video` controls. 285 | * 2. Correct inability to style clickable `input` types in iOS. 286 | * 3. Improve usability and consistency of cursor style between image-type 287 | * `input` and others. 288 | */ 289 | 290 | button, 291 | html input[type="button"], /* 1 */ 292 | input[type="reset"], 293 | input[type="submit"] { 294 | -webkit-appearance: button; /* 2 */ 295 | cursor: pointer; /* 3 */ 296 | } 297 | 298 | /** 299 | * Re-set default cursor for disabled elements. 300 | */ 301 | 302 | button[disabled], 303 | html input[disabled] { 304 | cursor: default; 305 | } 306 | 307 | /** 308 | * Remove inner padding and border in Firefox 4+. 309 | */ 310 | 311 | button::-moz-focus-inner, 312 | input::-moz-focus-inner { 313 | border: 0; 314 | padding: 0; 315 | } 316 | 317 | /** 318 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in 319 | * the UA stylesheet. 320 | */ 321 | 322 | input { 323 | line-height: normal; 324 | } 325 | 326 | /** 327 | * It's recommended that you don't attempt to style these elements. 328 | * Firefox's implementation doesn't respect box-sizing, padding, or width. 329 | * 330 | * 1. Address box sizing set to `content-box` in IE 8/9/10. 331 | * 2. Remove excess padding in IE 8/9/10. 332 | */ 333 | 334 | input[type="checkbox"], 335 | input[type="radio"] { 336 | box-sizing: border-box; /* 1 */ 337 | padding: 0; /* 2 */ 338 | } 339 | 340 | /** 341 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain 342 | * `font-size` values of the `input`, it causes the cursor style of the 343 | * decrement button to change from `default` to `text`. 344 | */ 345 | 346 | input[type="number"]::-webkit-inner-spin-button, 347 | input[type="number"]::-webkit-outer-spin-button { 348 | height: auto; 349 | } 350 | 351 | /** 352 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome. 353 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome 354 | * (include `-moz` to future-proof). 355 | */ 356 | 357 | input[type="search"] { 358 | -webkit-appearance: textfield; /* 1 */ 359 | -moz-box-sizing: content-box; 360 | -webkit-box-sizing: content-box; /* 2 */ 361 | box-sizing: content-box; 362 | } 363 | 364 | /** 365 | * Remove inner padding and search cancel button in Safari and Chrome on OS X. 366 | * Safari (but not Chrome) clips the cancel button when the search input has 367 | * padding (and `textfield` appearance). 368 | */ 369 | 370 | input[type="search"]::-webkit-search-cancel-button, 371 | input[type="search"]::-webkit-search-decoration { 372 | -webkit-appearance: none; 373 | } 374 | 375 | /** 376 | * Define consistent border, margin, and padding. 377 | */ 378 | 379 | fieldset { 380 | border: 1px solid #c0c0c0; 381 | margin: 0 2px; 382 | padding: 0.35em 0.625em 0.75em; 383 | } 384 | 385 | /** 386 | * 1. Correct `color` not being inherited in IE 8/9/10/11. 387 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 388 | */ 389 | 390 | legend { 391 | border: 0; /* 1 */ 392 | padding: 0; /* 2 */ 393 | } 394 | 395 | /** 396 | * Remove default vertical scrollbar in IE 8/9/10/11. 397 | */ 398 | 399 | textarea { 400 | overflow: auto; 401 | } 402 | 403 | /** 404 | * Don't inherit the `font-weight` (applied by a rule above). 405 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. 406 | */ 407 | 408 | optgroup { 409 | font-weight: bold; 410 | } 411 | 412 | /* Tables 413 | ========================================================================== */ 414 | 415 | /** 416 | * Remove most spacing between table cells. 417 | */ 418 | 419 | table { 420 | border-collapse: collapse; 421 | border-spacing: 0; 422 | } 423 | 424 | td, 425 | th { 426 | padding: 0; 427 | } 428 | -------------------------------------------------------------------------------- /docs/css/template.css: -------------------------------------------------------------------------------- 1 | 2 | .phpdocumentor-content { 3 | position: relative; 4 | display: flex; 5 | gap: var(--spacing-md); 6 | } 7 | 8 | .phpdocumentor-content > section:first-of-type { 9 | width: 75%; 10 | flex: 1 1 auto; 11 | } 12 | 13 | @media (min-width: 1900px) { 14 | .phpdocumentor-content > section:first-of-type { 15 | width: 100%; 16 | flex: 1 1 auto; 17 | } 18 | } 19 | 20 | .phpdocumentor .phpdocumentor-content__title { 21 | margin-top: 0; 22 | } 23 | .phpdocumentor-summary { 24 | font-style: italic; 25 | } 26 | .phpdocumentor-description { 27 | margin-bottom: var(--spacing-md); 28 | } 29 | .phpdocumentor-element { 30 | position: relative; 31 | } 32 | 33 | .phpdocumentor-element .phpdocumentor-element { 34 | border: 1px solid var(--primary-color-lighten); 35 | margin-bottom: var(--spacing-md); 36 | padding: var(--spacing-xs); 37 | border-radius: 5px; 38 | } 39 | 40 | .phpdocumentor-element.-deprecated .phpdocumentor-element__name { 41 | text-decoration: line-through; 42 | } 43 | 44 | @media (min-width: 550px) { 45 | .phpdocumentor-element .phpdocumentor-element { 46 | margin-bottom: var(--spacing-lg); 47 | padding: var(--spacing-md); 48 | } 49 | } 50 | 51 | .phpdocumentor-element__modifier { 52 | font-size: var(--text-xxs); 53 | padding: calc(var(--spacing-base-size) / 4) calc(var(--spacing-base-size) / 2); 54 | color: var(--text-color); 55 | background-color: var(--light-gray); 56 | border-radius: 3px; 57 | text-transform: uppercase; 58 | } 59 | 60 | .phpdocumentor .phpdocumentor-elements__header { 61 | margin-top: var(--spacing-xxl); 62 | margin-bottom: var(--spacing-lg); 63 | } 64 | 65 | .phpdocumentor .phpdocumentor-element__name { 66 | line-height: 1; 67 | margin-top: 0; 68 | font-weight: 300; 69 | font-size: var(--text-lg); 70 | word-break: break-all; 71 | margin-bottom: var(--spacing-sm); 72 | } 73 | 74 | @media (min-width: 550px) { 75 | .phpdocumentor .phpdocumentor-element__name { 76 | font-size: var(--text-xl); 77 | margin-bottom: var(--spacing-xs); 78 | } 79 | } 80 | 81 | @media (min-width: 1200px) { 82 | .phpdocumentor .phpdocumentor-element__name { 83 | margin-bottom: var(--spacing-md); 84 | } 85 | } 86 | 87 | .phpdocumentor-element__package, 88 | .phpdocumentor-element__extends, 89 | .phpdocumentor-element__implements { 90 | display: block; 91 | font-size: var(--text-xxs); 92 | font-weight: normal; 93 | opacity: .7; 94 | } 95 | 96 | .phpdocumentor-element__package .phpdocumentor-breadcrumbs { 97 | display: inline; 98 | } 99 | .phpdocumentor .phpdocumentor-signature { 100 | display: block; 101 | font-size: var(--text-sm); 102 | border: 1px solid #f0f0f0; 103 | } 104 | 105 | .phpdocumentor .phpdocumentor-signature.-deprecated .phpdocumentor-signature__name { 106 | text-decoration: line-through; 107 | } 108 | 109 | @media (min-width: 550px) { 110 | .phpdocumentor .phpdocumentor-signature { 111 | margin-left: calc(var(--spacing-xl) * -1); 112 | width: calc(100% + var(--spacing-xl)); 113 | } 114 | } 115 | 116 | .phpdocumentor-table-of-contents { 117 | } 118 | 119 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry { 120 | margin-bottom: var(--spacing-xxs); 121 | margin-left: 2rem; 122 | display: flex; 123 | } 124 | 125 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry > a { 126 | flex: 0 1 auto; 127 | } 128 | 129 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry > a.-deprecated { 130 | text-decoration: line-through; 131 | } 132 | 133 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry > span { 134 | flex: 1; 135 | white-space: nowrap; 136 | text-overflow: ellipsis; 137 | overflow: hidden; 138 | } 139 | 140 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry:after { 141 | content: ''; 142 | height: 12px; 143 | width: 12px; 144 | left: 16px; 145 | position: absolute; 146 | } 147 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-private:after { 148 | background: url('data:image/svg+xml;utf8,') no-repeat; 149 | } 150 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-protected:after { 151 | left: 13px; 152 | background: url('data:image/svg+xml;utf8,') no-repeat; 153 | } 154 | 155 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry:before { 156 | width: 1.25rem; 157 | height: 1.25rem; 158 | line-height: 1.25rem; 159 | background: transparent url('data:image/svg+xml;utf8,') no-repeat center center; 160 | content: ''; 161 | position: absolute; 162 | left: 0; 163 | border-radius: 50%; 164 | font-weight: 600; 165 | color: white; 166 | text-align: center; 167 | font-size: .75rem; 168 | margin-top: .2rem; 169 | } 170 | 171 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-method:before { 172 | content: 'M'; 173 | color: ''; 174 | background-image: url('data:image/svg+xml;utf8,'); 175 | } 176 | 177 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-function:before { 178 | content: 'M'; 179 | color: ' 45'; 180 | background-image: url('data:image/svg+xml;utf8,'); 181 | } 182 | 183 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-property:before { 184 | content: 'P' 185 | } 186 | 187 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-constant:before { 188 | content: 'C'; 189 | background-color: transparent; 190 | background-image: url('data:image/svg+xml;utf8,'); 191 | } 192 | 193 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-class:before { 194 | content: 'C' 195 | } 196 | 197 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-interface:before { 198 | content: 'I' 199 | } 200 | 201 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-trait:before { 202 | content: 'T' 203 | } 204 | 205 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-namespace:before { 206 | content: 'N' 207 | } 208 | 209 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-package:before { 210 | content: 'P' 211 | } 212 | 213 | .phpdocumentor-table-of-contents .phpdocumentor-table-of-contents__entry.-enum:before { 214 | content: 'E' 215 | } 216 | 217 | .phpdocumentor-table-of-contents dd { 218 | font-style: italic; 219 | margin-left: 2rem; 220 | } 221 | .phpdocumentor-element-found-in { 222 | display: none; 223 | } 224 | 225 | @media (min-width: 550px) { 226 | .phpdocumentor-element-found-in { 227 | display: block; 228 | font-size: var(--text-sm); 229 | color: gray; 230 | margin-bottom: 1rem; 231 | } 232 | } 233 | 234 | @media (min-width: 1200px) { 235 | .phpdocumentor-element-found-in { 236 | position: absolute; 237 | top: var(--spacing-sm); 238 | right: var(--spacing-sm); 239 | font-size: var(--text-sm); 240 | margin-bottom: 0; 241 | } 242 | } 243 | 244 | .phpdocumentor-element-found-in .phpdocumentor-element-found-in__source { 245 | flex: 0 1 auto; 246 | display: inline-flex; 247 | } 248 | 249 | .phpdocumentor-element-found-in .phpdocumentor-element-found-in__source:after { 250 | width: 1.25rem; 251 | height: 1.25rem; 252 | line-height: 1.25rem; 253 | background: transparent url('data:image/svg+xml;utf8,') no-repeat center center; 254 | content: ''; 255 | left: 0; 256 | border-radius: 50%; 257 | font-weight: 600; 258 | text-align: center; 259 | font-size: .75rem; 260 | margin-top: .2rem; 261 | } 262 | .phpdocumentor-class-graph { 263 | width: 100%; height: 600px; border:1px solid black; overflow: hidden 264 | } 265 | 266 | .phpdocumentor-class-graph__graph { 267 | width: 100%; 268 | } 269 | .phpdocumentor-tag-list__definition { 270 | display: flex; 271 | } 272 | 273 | .phpdocumentor-tag-link { 274 | margin-right: var(--spacing-sm); 275 | } 276 | .phpdocumentor-title__link { 277 | margin-right: 1em; 278 | white-space: break-spaces; 279 | } 280 | .phpdocumentor-title__link:hover { 281 | transform: none; 282 | } 283 | .phpdocumentor-uml-diagram svg { 284 | cursor: zoom-in; 285 | } -------------------------------------------------------------------------------- /docs/files/src-fusionauth-clientresponse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |

FusionAuth PHP Client

29 | 30 | 33 | 43 | 44 | 48 |
49 | 50 |
51 |
52 | 53 | 56 | 88 | 89 |
90 |
91 |
    92 |
93 | 94 |
95 |

ClientResponse.php

96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |

107 | Table of Contents 108 | 109 | 110 |

111 | 112 | 113 | 114 | 115 |

116 | Classes 117 | 118 | 119 |

120 |
121 |
ClientResponse
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
136 |
137 |
138 |
139 |

140 |         
141 | 142 |
143 |
144 | 145 | 226 | 227 |
228 |
229 |
230 | 231 |
232 | On this page 233 | 234 |
    235 |
  • Table Of Contents
  • 236 |
  • 237 | 240 |
  • 241 | 242 | 243 |
244 |
245 | 246 |
247 |
248 |
249 |
250 |
251 |

Search results

252 | 253 |
254 |
255 |
    256 |
    257 |
    258 |
    259 |
    260 | 261 | 262 |
    263 | 264 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /docs/files/src-fusionauth-fusionauthclient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
    28 |

    FusionAuth PHP Client

    29 | 30 | 33 | 43 | 44 | 48 |
    49 | 50 |
    51 |
    52 | 53 | 56 | 88 | 89 |
    90 |
    91 |
      92 |
    93 | 94 |
    95 |

    FusionAuthClient.php

    96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |

    107 | Table of Contents 108 | 109 | 110 |

    111 | 112 | 113 | 114 | 115 |

    116 | Classes 117 | 118 | 119 |

    120 |
    121 |
    FusionAuthClient
    Client that connects to a FusionAuth server and provides access to the full set of FusionAuth APIs.
    122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
    136 |
    137 |
    138 |
    139 |
    
    140 |         
    141 | 142 |
    143 |
    144 | 145 | 226 | 227 |
    228 |
    229 |
    230 | 231 |
    232 | On this page 233 | 234 |
      235 |
    • Table Of Contents
    • 236 |
    • 237 | 240 |
    • 241 | 242 | 243 |
    244 |
    245 | 246 |
    247 |
    248 |
    249 |
    250 |
    251 |

    Search results

    252 | 253 |
    254 |
    255 |
      256 |
      257 |
      258 |
      259 |
      260 | 261 | 262 |
      263 | 264 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /docs/files/src-fusionauth-restclient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
      28 |

      FusionAuth PHP Client

      29 | 30 | 33 | 43 | 44 | 48 |
      49 | 50 |
      51 |
      52 | 53 | 56 | 88 | 89 |
      90 |
      91 |
        92 |
      93 | 94 |
      95 |

      RESTClient.php

      96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |

      107 | Table of Contents 108 | 109 | 110 |

      111 | 112 | 113 | 114 |

      115 | Interfaces 116 | 117 | 118 |

      119 |
      120 |
      BodyHandler
      ResponseHandler
      121 | 122 |

      123 | Classes 124 | 125 | 126 |

      127 |
      128 |
      RESTClient
      FormDataBodyHandler
      JSONBodyHandler
      JSONResponseHandler
      129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |
      143 |
      144 |
      145 |
      146 |
      
      147 |         
      148 | 149 |
      150 |
      151 | 152 | 233 | 234 |
      235 |
      236 |
      237 | 238 |
      239 | On this page 240 | 241 |
        242 |
      • Table Of Contents
      • 243 |
      • 244 | 248 |
      • 249 | 250 | 251 |
      252 |
      253 | 254 |
      255 |
      256 |
      257 |
      258 |
      259 |

      Search results

      260 | 261 |
      262 |
      263 |
        264 |
        265 |
        266 |
        267 |
        268 | 269 | 270 |
        271 | 272 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /docs/files/tests-fusionauth-fusionauthclienttest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
        28 |

        FusionAuth PHP Client

        29 | 30 | 33 | 43 | 44 | 48 |
        49 | 50 |
        51 |
        52 | 53 | 56 | 88 | 89 |
        90 |
        91 |
          92 |
        93 | 94 |
        95 |

        FusionAuthClientTest.php

        96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |

        107 | Table of Contents 108 | 109 | 110 |

        111 | 112 | 113 | 114 | 115 |

        116 | Classes 117 | 118 | 119 |

        120 |
        121 |
        FusionAuthClientTest
        122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
        136 |
        137 |
        138 |
        139 |
        
        140 |         
        141 | 142 |
        143 |
        144 | 145 | 226 | 227 |
        228 |
        229 |
        230 | 231 |
        232 | On this page 233 | 234 |
          235 |
        • Table Of Contents
        • 236 |
        • 237 | 240 |
        • 241 | 242 | 243 |
        244 |
        245 | 246 |
        247 |
        248 |
        249 |
        250 |
        251 |

        Search results

        252 | 253 |
        254 |
        255 |
          256 |
          257 |
          258 |
          259 |
          260 | 261 | 262 |
          263 | 264 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /docs/graphs/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
          16 |

          FusionAuth PHP Client

          17 | 18 | 21 | 31 | 32 | 36 |
          37 | 38 |
          39 |
          40 | 41 | 44 | 76 | 77 |
          78 |
          79 | 80 |
          81 | 89 |
          90 |
          91 |
          92 |
          93 |

          Search results

          94 | 95 |
          96 |
          97 |
            98 |
            99 |
            100 |
            101 |
            102 | 103 | 104 |
            105 | 106 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
            28 |

            FusionAuth PHP Client

            29 | 30 | 33 | 43 | 44 | 48 |
            49 | 50 |
            51 |
            52 | 53 | 56 | 88 | 89 |
            90 |
            91 |

            Documentation

            92 | 93 | 94 | 95 |

            96 | Table of Contents 97 | 98 | 99 |

            100 | 101 |

            102 | Packages 103 | 104 | 105 |

            106 |
            107 |
            Application
            108 |
            109 | 110 |

            111 | Namespaces 112 | 113 | 114 |

            115 |
            116 |
            FusionAuth
            117 |
            Tests
            118 |
            119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 |
            133 |
            134 |
            135 |
            136 |
            137 |

            Search results

            138 | 139 |
            140 |
            141 |
              142 |
              143 |
              144 |
              145 |
              146 | 147 | 148 |
              149 | 150 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /docs/indices/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
              28 |

              FusionAuth PHP Client

              29 | 30 | 33 | 43 | 44 | 48 |
              49 | 50 |
              51 |
              52 | 53 | 56 | 88 | 89 |
              90 |
              91 | 92 |

              Files

              93 |

              C

              94 | 97 |

              F

              98 | 102 |

              R

              103 | 106 |
              107 |
              108 |
              109 |
              110 |
              111 |

              Search results

              112 | 113 |
              114 |
              115 |
                116 |
                117 |
                118 |
                119 |
                120 | 121 | 122 |
                123 | 124 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /docs/js/search.js: -------------------------------------------------------------------------------- 1 | // Search module for phpDocumentor 2 | // 3 | // This module is a wrapper around fuse.js that will use a given index and attach itself to a 4 | // search form and to a search results pane identified by the following data attributes: 5 | // 6 | // 1. data-search-form 7 | // 2. data-search-results 8 | // 9 | // The data-search-form is expected to have a single input element of type 'search' that will trigger searching for 10 | // a series of results, were the data-search-results pane is expected to have a direct UL child that will be populated 11 | // with rendered results. 12 | // 13 | // The search has various stages, upon loading this stage the data-search-form receives the CSS class 14 | // 'phpdocumentor-search--enabled'; this indicates that JS is allowed and indices are being loaded. It is recommended 15 | // to hide the form by default and show it when it receives this class to achieve progressive enhancement for this 16 | // feature. 17 | // 18 | // After loading this module, it is expected to load a search index asynchronously, for example: 19 | // 20 | // 21 | // 22 | // In this script the generated index should attach itself to the search module using the `appendIndex` function. By 23 | // doing it like this the page will continue loading, unhindered by the loading of the search. 24 | // 25 | // After the page has fully loaded, and all these deferred indexes loaded, the initialization of the search module will 26 | // be called and the form will receive the class 'phpdocumentor-search--active', indicating search is ready. At this 27 | // point, the input field will also have it's 'disabled' attribute removed. 28 | var Search = (function () { 29 | var fuse; 30 | var index = []; 31 | var options = { 32 | shouldSort: true, 33 | threshold: 0.6, 34 | location: 0, 35 | distance: 100, 36 | maxPatternLength: 32, 37 | minMatchCharLength: 1, 38 | keys: [ 39 | "fqsen", 40 | "name", 41 | "summary", 42 | "url" 43 | ] 44 | }; 45 | 46 | // Credit David Walsh (https://davidwalsh.name/javascript-debounce-function) 47 | // Returns a function, that, as long as it continues to be invoked, will not 48 | // be triggered. The function will be called after it stops being called for 49 | // N milliseconds. If `immediate` is passed, trigger the function on the 50 | // leading edge, instead of the trailing. 51 | function debounce(func, wait, immediate) { 52 | var timeout; 53 | 54 | return function executedFunction() { 55 | var context = this; 56 | var args = arguments; 57 | 58 | var later = function () { 59 | timeout = null; 60 | if (!immediate) func.apply(context, args); 61 | }; 62 | 63 | var callNow = immediate && !timeout; 64 | clearTimeout(timeout); 65 | timeout = setTimeout(later, wait); 66 | if (callNow) func.apply(context, args); 67 | }; 68 | } 69 | 70 | function close() { 71 | // Start scroll prevention: https://css-tricks.com/prevent-page-scrolling-when-a-modal-is-open/ 72 | const scrollY = document.body.style.top; 73 | document.body.style.position = ''; 74 | document.body.style.top = ''; 75 | window.scrollTo(0, parseInt(scrollY || '0') * -1); 76 | // End scroll prevention 77 | 78 | var form = document.querySelector('[data-search-form]'); 79 | var searchResults = document.querySelector('[data-search-results]'); 80 | 81 | form.classList.toggle('phpdocumentor-search--has-results', false); 82 | searchResults.classList.add('phpdocumentor-search-results--hidden'); 83 | var searchField = document.querySelector('[data-search-form] input[type="search"]'); 84 | searchField.blur(); 85 | } 86 | 87 | function search(event) { 88 | // Start scroll prevention: https://css-tricks.com/prevent-page-scrolling-when-a-modal-is-open/ 89 | document.body.style.position = 'fixed'; 90 | document.body.style.top = `-${window.scrollY}px`; 91 | // End scroll prevention 92 | 93 | // prevent enter's from autosubmitting 94 | event.stopPropagation(); 95 | 96 | var form = document.querySelector('[data-search-form]'); 97 | var searchResults = document.querySelector('[data-search-results]'); 98 | var searchResultEntries = document.querySelector('[data-search-results] .phpdocumentor-search-results__entries'); 99 | 100 | searchResultEntries.innerHTML = ''; 101 | 102 | if (!event.target.value) { 103 | close(); 104 | return; 105 | } 106 | 107 | form.classList.toggle('phpdocumentor-search--has-results', true); 108 | searchResults.classList.remove('phpdocumentor-search-results--hidden'); 109 | var results = fuse.search(event.target.value, {limit: 25}); 110 | 111 | results.forEach(function (result) { 112 | var entry = document.createElement("li"); 113 | entry.classList.add("phpdocumentor-search-results__entry"); 114 | entry.innerHTML += '

                ' + result.name + "

                \n"; 115 | entry.innerHTML += '' + result.fqsen + "\n"; 116 | entry.innerHTML += '
                ' + result.summary + '
                '; 117 | searchResultEntries.appendChild(entry) 118 | }); 119 | } 120 | 121 | function appendIndex(added) { 122 | index = index.concat(added); 123 | 124 | // re-initialize search engine when appending an index after initialisation 125 | if (typeof fuse !== 'undefined') { 126 | fuse = new Fuse(index, options); 127 | } 128 | } 129 | 130 | function init() { 131 | fuse = new Fuse(index, options); 132 | 133 | var form = document.querySelector('[data-search-form]'); 134 | var searchField = document.querySelector('[data-search-form] input[type="search"]'); 135 | 136 | var closeButton = document.querySelector('.phpdocumentor-search-results__close'); 137 | closeButton.addEventListener('click', function() { close() }.bind(this)); 138 | 139 | var searchResults = document.querySelector('[data-search-results]'); 140 | searchResults.addEventListener('click', function() { close() }.bind(this)); 141 | 142 | form.classList.add('phpdocumentor-search--active'); 143 | 144 | searchField.setAttribute('placeholder', 'Search (Press "/" to focus)'); 145 | searchField.removeAttribute('disabled'); 146 | searchField.addEventListener('keyup', debounce(search, 300)); 147 | 148 | window.addEventListener('keyup', function (event) { 149 | if (event.key === '/') { 150 | searchField.focus(); 151 | } 152 | if (event.code === 'Escape') { 153 | close(); 154 | } 155 | }.bind(this)); 156 | } 157 | 158 | return { 159 | appendIndex, 160 | init 161 | } 162 | })(); 163 | 164 | window.addEventListener('DOMContentLoaded', function () { 165 | var form = document.querySelector('[data-search-form]'); 166 | 167 | // When JS is supported; show search box. Must be before including the search for it to take effect immediately 168 | form.classList.add('phpdocumentor-search--enabled'); 169 | }); 170 | 171 | window.addEventListener('load', function () { 172 | Search.init(); 173 | }); 174 | -------------------------------------------------------------------------------- /docs/js/template.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | window.addEventListener('load', () => { 3 | const el = document.querySelector('.phpdocumentor-on-this-page__content') 4 | if (!el) { 5 | return; 6 | } 7 | 8 | const observer = new IntersectionObserver( 9 | ([e]) => { 10 | e.target.classList.toggle("-stuck", e.intersectionRatio < 1); 11 | }, 12 | {threshold: [1]} 13 | ); 14 | 15 | observer.observe(el); 16 | }) 17 | })(); 18 | function openSvg(svg) { 19 | // convert to a valid XML source 20 | const as_text = new XMLSerializer().serializeToString(svg); 21 | // store in a Blob 22 | const blob = new Blob([as_text], { type: "image/svg+xml" }); 23 | // create an URI pointing to that blob 24 | const url = URL.createObjectURL(blob); 25 | const win = open(url); 26 | // so the Garbage Collector can collect the blob 27 | win.onload = (evt) => URL.revokeObjectURL(url); 28 | }; 29 | 30 | 31 | var svgs = document.querySelectorAll(".phpdocumentor-uml-diagram svg"); 32 | for( var i=0,il = svgs.length; i< il; i ++ ) { 33 | svgs[i].onclick = (evt) => openSvg(evt.target); 34 | } -------------------------------------------------------------------------------- /docs/namespaces/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
                28 |

                FusionAuth PHP Client

                29 | 30 | 33 | 43 | 44 | 48 |
                49 | 50 |
                51 |
                52 | 53 | 56 | 88 | 89 |
                90 |
                91 |
                  92 |
                93 | 94 |
                95 |

                API Documentation

                96 | 97 | 98 |

                99 | Table of Contents 100 | 101 | 102 |

                103 | 104 | 105 |

                106 | Namespaces 107 | 108 | 109 |

                110 |
                111 |
                FusionAuth
                112 |
                Tests
                113 |
                114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
                128 |
                129 |
                130 |
                131 |
                
                132 |         
                133 | 134 |
                135 |
                136 | 137 | 218 | 219 |
                220 |
                221 |
                222 | 223 |
                224 | On this page 225 | 226 |
                  227 |
                • Table Of Contents
                • 228 |
                • 229 |
                    230 |
                  231 |
                • 232 | 233 | 234 |
                235 |
                236 | 237 |
                238 |
                239 |
                240 |
                241 |
                242 |

                Search results

                243 | 244 |
                245 |
                246 |
                  247 |
                  248 |
                  249 |
                  250 |
                  251 | 252 | 253 |
                  254 | 255 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | -------------------------------------------------------------------------------- /docs/namespaces/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
                  28 |

                  FusionAuth PHP Client

                  29 | 30 | 33 | 43 | 44 | 48 |
                  49 | 50 |
                  51 |
                  52 | 53 | 56 | 88 | 89 |
                  90 |
                  91 |
                    92 |
                  93 | 94 |
                  95 |

                  Tests

                  96 | 97 | 98 |

                  99 | Table of Contents 100 | 101 | 102 |

                  103 | 104 | 105 | 106 | 107 |

                  108 | Classes 109 | 110 | 111 |

                  112 |
                  113 |
                  FusionAuthClientTest
                  114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 |
                  126 |
                  127 |
                  128 |
                  129 |
                  
                  130 |         
                  131 | 132 |
                  133 |
                  134 | 135 | 216 | 217 |
                  218 |
                  219 |
                  220 | 221 |
                  222 | On this page 223 | 224 |
                    225 |
                  • Table Of Contents
                  • 226 |
                  • 227 | 230 |
                  • 231 | 232 | 233 |
                  234 |
                  235 | 236 |
                  237 |
                  238 |
                  239 |
                  240 |
                  241 |

                  Search results

                  242 | 243 |
                  244 |
                  245 |
                    246 |
                    247 |
                    248 |
                    249 |
                    250 | 251 | 252 |
                    253 | 254 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /docs/packages/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
                    28 |

                    FusionAuth PHP Client

                    29 | 30 | 33 | 43 | 44 | 48 |
                    49 | 50 |
                    51 |
                    52 | 53 | 56 | 88 | 89 |
                    90 |
                    91 |
                      92 |
                    93 | 94 |
                    95 |

                    API Documentation

                    96 | 97 | 98 |

                    99 | Table of Contents 100 | 101 | 102 |

                    103 | 104 |

                    105 | Packages 106 | 107 | 108 |

                    109 |
                    110 |
                    Application
                    111 |
                    112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 |
                    127 |
                    128 |
                    129 |
                    130 |
                    
                    131 |         
                    132 | 133 |
                    134 |
                    135 | 136 | 217 | 218 |
                    219 |
                    220 |
                    221 | 222 |
                    223 | On this page 224 | 225 |
                      226 |
                    • Table Of Contents
                    • 227 |
                    • 228 |
                        229 |
                      230 |
                    • 231 | 232 | 233 |
                    234 |
                    235 | 236 |
                    237 |
                    238 |
                    239 |
                    240 |
                    241 |

                    Search results

                    242 | 243 |
                    244 |
                    245 |
                      246 |
                      247 |
                      248 |
                      249 |
                      250 | 251 | 252 |
                      253 | 254 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /docs/reports/deprecated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client » Deprecated elements 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
                      29 |

                      FusionAuth PHP Client

                      30 | 31 | 34 | 44 | 45 | 49 |
                      50 | 51 |
                      52 |
                      53 | 54 | 57 | 89 | 90 |
                      91 |
                      92 | 95 | 96 |
                      97 |

                      Deprecated

                      98 | 99 |

                      Table of Contents

                      100 | 101 | 102 | 103 | 104 |
                      src/FusionAuth/FusionAuthClient.php
                      105 | 106 | 107 |

                      FusionAuthClient.php

                      108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 119 | 120 | 121 | 122 | 123 | 125 | 126 | 127 | 128 | 129 | 131 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 141 | 143 | 144 | 145 | 146 | 147 | 149 | 150 | 151 | 152 | 153 | 155 | 156 | 157 | 158 | 159 | 161 | 162 |
                      LineElementReason
                      963FusionAuthClient::deactivateUsers()

                      This method has been renamed to deactivateUsersByIds, use that method instead.

                      118 |
                      1560FusionAuthClient::deleteUsers()

                      This method has been renamed to deleteUsersByQuery, use that method instead.

                      124 |
                      5112FusionAuthClient::searchUsers()

                      This method has been renamed to searchUsersByIds, use that method instead.

                      130 |
                      5163FusionAuthClient::searchUsersByQueryString()

                      This method has been renamed to searchUsersByQuery, use that method instead.

                      136 |
                      5263FusionAuthClient::sendTwoFactorCode()

                      This method has been renamed to sendTwoFactorCodeForEnableDisable, use that method instead.

                      142 |
                      5296FusionAuthClient::sendTwoFactorCodeForLogin()

                      This method has been renamed to sendTwoFactorCodeForLoginUsingMethod, use that method instead.

                      148 |
                      6058FusionAuthClient::verifyEmail()

                      This method has been renamed to verifyEmailAddress and changed to take a JSON request body, use that method instead.

                      154 |
                      6114FusionAuthClient::verifyRegistration()

                      This method has been renamed to verifyUserRegistration and changed to take a JSON request body, use that method instead.

                      160 |
                      163 |
                      164 |
                      165 |
                      166 |
                      167 |
                      168 |
                      169 |

                      Search results

                      170 | 171 |
                      172 |
                      173 |
                        174 |
                        175 |
                        176 |
                        177 |
                        178 | 179 | 180 |
                        181 | 182 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /docs/reports/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client » Compilation errors 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
                        29 |

                        FusionAuth PHP Client

                        30 | 31 | 34 | 44 | 45 | 49 |
                        50 | 51 |
                        52 |
                        53 | 54 | 57 | 89 | 90 |
                        91 |
                        92 | 95 | 96 |
                        97 |

                        Errors

                        98 | 99 | 100 |
                        No errors have been found in this project.
                        101 | 102 |
                        103 |
                        104 |
                        105 |
                        106 |
                        107 |
                        108 |

                        Search results

                        109 | 110 |
                        111 |
                        112 |
                          113 |
                          114 |
                          115 |
                          116 |
                          117 | 118 | 119 |
                          120 | 121 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /docs/reports/markers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FusionAuth PHP Client » Markers 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
                          29 |

                          FusionAuth PHP Client

                          30 | 31 | 34 | 44 | 45 | 49 |
                          50 | 51 |
                          52 |
                          53 | 54 | 57 | 89 | 90 |
                          91 |
                          92 | 95 | 96 |
                          97 |

                          Markers

                          98 | 99 |
                          100 | No markers have been found in this project. 101 |
                          102 | 103 |
                          104 |
                          105 |
                          106 |
                          107 |
                          108 |
                          109 |

                          Search results

                          110 | 111 |
                          112 |
                          113 |
                            114 |
                            115 |
                            116 |
                            117 |
                            118 | 119 | 120 |
                            121 | 122 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /fusionauth-php-client.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /phpdoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | FusionAuth PHP Client 8 | 9 | docs/ 10 | 11 | 12 | 13 | 14 | src 15 | tests 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | tests 16 | 17 | 18 | 19 | 20 | 21 | src 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/FusionAuth/ClientResponse.php: -------------------------------------------------------------------------------- 1 | status >= 200 && $this->status <= 299 && $this->exception == null; 38 | } 39 | 40 | public function __construct() 41 | { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/FusionAuth/RESTClient.php: -------------------------------------------------------------------------------- 1 | resetAuthorizationHeaders(); 94 | 95 | // Add the Authorization header. 96 | $this->headers[] = 'Authorization: ' . $key; 97 | 98 | return $this; 99 | } 100 | 101 | public function basicAuthorization($username, $password) 102 | { 103 | if (!is_null($username) && !is_null($password)) { 104 | // Remove any Authorization headers before adding a new one. 105 | $this->resetAuthorizationHeaders(); 106 | 107 | // Add the Authorization header. 108 | $credentials = $username . ':' . $password; 109 | $encoded = base64_encode($credentials); 110 | $this->headers[] = 'Authorization: ' . 'Basic ' . $encoded; 111 | } 112 | 113 | return $this; 114 | } 115 | 116 | protected function resetAuthorizationHeaders() 117 | { 118 | $headers = []; 119 | foreach ($this->headers as $value) { 120 | if (stripos($value, "Authorization:") !== 0) { 121 | $headers[] = $value; 122 | } 123 | } 124 | $this->headers = $headers; 125 | } 126 | 127 | public function bodyHandler($bodyHandler) 128 | { 129 | $this->bodyHandler = $bodyHandler; 130 | return $this; 131 | } 132 | 133 | public function certificate($certificate) 134 | { 135 | $this->certificate = $certificate; 136 | return $this; 137 | } 138 | 139 | public function connectTimeout($connectTimeout) 140 | { 141 | $this->connectTimeout = $connectTimeout; 142 | return $this; 143 | } 144 | 145 | public function delete() 146 | { 147 | $this->method = 'DELETE'; 148 | return $this; 149 | } 150 | 151 | public function errorResponseHandler($errorResponseHandler) 152 | { 153 | $this->errorResponseHandler = $errorResponseHandler; 154 | return $this; 155 | } 156 | 157 | public function get() 158 | { 159 | $this->method = 'GET'; 160 | return $this; 161 | } 162 | 163 | public function go() 164 | { 165 | if (!$this->url || (bool)parse_url($this->url, PHP_URL_HOST) === false) { 166 | throw new \Exception('You must specify a URL'); 167 | } 168 | 169 | if (!$this->method) { 170 | throw new \Exception('You must specify a HTTP method'); 171 | } 172 | 173 | $response = new ClientResponse(); 174 | $response->request = ($this->bodyHandler != null) ? $this->bodyHandler->bodyObject() : null; 175 | $response->method = $this->method; 176 | 177 | try { 178 | if ($this->parameters) { 179 | if (substr($this->url, -1) != '?') { 180 | $this->url = $this->url . '?'; 181 | } 182 | 183 | $parts = array(); 184 | foreach ($this->parameters as $key => $value) { 185 | if (is_array($value)) { 186 | foreach ($value as $value2) { 187 | $parts[] = http_build_query(array($key => $value2)); 188 | } 189 | } else { 190 | $parts[] = http_build_query(array($key => $value)); 191 | } 192 | } 193 | $params = join('&', $parts); 194 | $this->url = $this->url . $params; 195 | } 196 | 197 | $curl = curl_init(); 198 | if (str_starts_with($this->url, 'https') && !empty($this->certificate)) { 199 | curl_setopt($curl, CURLOPT_SSLCERT, $this->certificate); 200 | if (!empty($this->key)) { 201 | curl_setopt($curl, CURLOPT_SSLKEY, $this->key); 202 | } 203 | } 204 | 205 | if ($this->proxy) { 206 | curl_setopt($curl, CURLOPT_PROXY, $this->proxy['url']); 207 | if (isset($this->proxy['auth'])) { 208 | curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->proxy['auth']); 209 | } 210 | } 211 | 212 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout); 213 | curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->readTimeout); 214 | curl_setopt($curl, CURLOPT_URL, $this->url); 215 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 216 | curl_setopt($curl, CURLOPT_POST, false); 217 | curl_setopt($curl, CURLOPT_FAILONERROR, false); 218 | 219 | if ($this->method === 'POST') { 220 | curl_setopt($curl, CURLOPT_POST, true); 221 | } elseif ($this->method !== 'GET') { 222 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->method); 223 | } 224 | 225 | if ($this->bodyHandler) { 226 | $this->bodyHandler->setHeaders($this->headers); 227 | } 228 | 229 | if ($this->bodyHandler) { 230 | $body = $this->bodyHandler->body(); 231 | if (!empty($body)) { 232 | curl_setopt($curl, CURLOPT_POSTFIELDS, $body); 233 | } 234 | } elseif (!\in_array('Content-Type: application/json', $this->headers)) { 235 | // Making sure we have 'application/json' set 236 | $this->headers[] = 'Content-Type: application/json'; 237 | } 238 | if (($this->method === 'POST') && (empty($body))) { 239 | // Making sure we always have a body 240 | curl_setopt($curl, CURLOPT_POSTFIELDS, ''); 241 | } 242 | 243 | // https://www.php.net/manual/pt_BR/function.curl-setopt.php#108137 244 | if (empty($body)) { 245 | if (!\in_array('Expect:', $this->headers)) { 246 | $this->headers[] = 'Expect:'; 247 | } 248 | } 249 | 250 | curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers); 251 | 252 | $result = curl_exec($curl); 253 | 254 | $response->status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 255 | if ($response->status < 200 || $response->status > 299) { 256 | if ($result) { 257 | $response->errorResponse = $this->errorResponseHandler->call($result); 258 | } 259 | } else { 260 | if ($result) { 261 | $response->successResponse = $this->successResponseHandler->call($result); 262 | } 263 | } 264 | 265 | curl_close($curl); 266 | return $response; 267 | } catch (\Exception $e) { 268 | if (isset($curl)) { 269 | curl_close($curl); 270 | } 271 | 272 | $response->exception = $e; 273 | return $response; 274 | } 275 | } 276 | 277 | public function header($name, $value) 278 | { 279 | $this->headers[] = $name . ': ' . $value; 280 | return $this; 281 | } 282 | 283 | public function headers($headers) 284 | { 285 | $this->headers = $headers; 286 | return $this; 287 | } 288 | 289 | public function patch() 290 | { 291 | $this->method = 'PATCH'; 292 | return $this; 293 | } 294 | 295 | public function post() 296 | { 297 | $this->method = 'POST'; 298 | return $this; 299 | } 300 | 301 | public function put() 302 | { 303 | $this->method = 'PUT'; 304 | return $this; 305 | } 306 | 307 | public function readTimeout($readTimeout) 308 | { 309 | $this->readTimeout = $readTimeout; 310 | return $this; 311 | } 312 | 313 | public function successResponseHandler($successResponseHandler) 314 | { 315 | $this->successResponseHandler = $successResponseHandler; 316 | return $this; 317 | } 318 | 319 | public function uri($uri) 320 | { 321 | if (!$this->url) { 322 | return $this; 323 | } 324 | 325 | if (substr($this->url, -1) == '/' && substr($uri, 1, 1) == '/') { 326 | $this->url = $this->url . ltrim($uri, '/'); 327 | } elseif (substr($this->url, -1) != '/' && substr($uri, 0, 1) != '/') { 328 | $this->url = $this->url . '/' . $uri; 329 | } else { 330 | $this->url = $this->url . $uri; 331 | } 332 | 333 | return $this; 334 | } 335 | 336 | public function url($url) 337 | { 338 | $this->url = $url; 339 | return $this; 340 | } 341 | 342 | public function urlParameter($name, $value) 343 | { 344 | if (!isset($value)) { 345 | return $this; 346 | } 347 | 348 | if (is_array($value)) { 349 | $this->parameters[$name] = $value; 350 | } else { 351 | if (!isset($this->parameters[$name])) { 352 | $this->parameters[$name] = array(); 353 | } 354 | 355 | if (is_bool($value)) { 356 | $this->parameters[$name][] = var_export($value, true); 357 | } else { 358 | $this->parameters[$name][] = $value; 359 | } 360 | } 361 | 362 | return $this; 363 | } 364 | 365 | public function urlSegment($value) 366 | { 367 | if (isset($value)) { 368 | if (substr($this->url, -1) != '/') { 369 | $this->url = $this->url . '/'; 370 | } 371 | $this->url = $this->url . $value; 372 | } 373 | return $this; 374 | } 375 | } 376 | 377 | interface BodyHandler 378 | { 379 | /** 380 | * @return string The body as a string. 381 | */ 382 | public function body(); 383 | 384 | /** 385 | * @return mixed The body as an object (usually an array). 386 | */ 387 | public function bodyObject(); 388 | 389 | /** 390 | * Sets body handler specific headers (like Content-Type). 391 | * 392 | * @param array $headers The headers array to add headers to. 393 | */ 394 | public function setHeaders(&$headers); 395 | } 396 | 397 | class FormDataBodyHandler implements BodyHandler 398 | { 399 | private $body; 400 | 401 | private $bodyObject; 402 | 403 | public function __construct(&$bodyObject) 404 | { 405 | $this->bodyObject = $bodyObject; 406 | $this->body = http_build_query($bodyObject); 407 | } 408 | 409 | public function body() 410 | { 411 | return $this->body; 412 | } 413 | 414 | public function bodyObject() 415 | { 416 | return $this->bodyObject; 417 | } 418 | 419 | public function setHeaders(&$headers) 420 | { 421 | /* body() will return a URL encoded body, CURLOPT_POSTFIELDS will then set the header 422 | to ContentType: application/x-www-form-urlencoded 423 | */ 424 | } 425 | } 426 | 427 | class JSONBodyHandler implements BodyHandler 428 | { 429 | private $body; 430 | 431 | private $bodyObject; 432 | 433 | public function __construct(&$bodyObject) 434 | { 435 | $this->bodyObject = $bodyObject; 436 | 437 | if (is_string($bodyObject)) { 438 | $bodyObject = json_decode($bodyObject); 439 | } 440 | if (is_object($bodyObject)) { 441 | $bodyObject = (array) $bodyObject; 442 | } 443 | 444 | $this->body = json_encode(array_filter($bodyObject)); 445 | } 446 | 447 | public function body() 448 | { 449 | return $this->body; 450 | } 451 | 452 | public function bodyObject() 453 | { 454 | return $this->bodyObject; 455 | } 456 | 457 | public function setHeaders(&$headers) 458 | { 459 | $headers[] = 'Content-Length: ' . strlen($this->body); 460 | $headers[] = 'Content-Type: application/json'; 461 | } 462 | } 463 | 464 | interface ResponseHandler 465 | { 466 | /** 467 | * Handles the HTTP response. 468 | * 469 | * @param string $response The HTTP response as a String. 470 | * @return mixed The response as an object. 471 | */ 472 | public function call(&$response); 473 | } 474 | 475 | class JSONResponseHandler implements ResponseHandler 476 | { 477 | public function call(&$response) 478 | { 479 | return json_decode($response); 480 | } 481 | } 482 | -------------------------------------------------------------------------------- /tests/FusionAuth/FusionAuthClientTest.php: -------------------------------------------------------------------------------- 1 | client = new FusionAuthClient($fusionauthApiKey, $fusionauthURL); 27 | } 28 | 29 | protected function tearDown(): void 30 | { 31 | if (isset($this->applicationId)) { 32 | $this->client->deleteApplication($this->applicationId); 33 | } 34 | if (isset($this->userId)) { 35 | $this->client->deleteUser($this->userId); 36 | } 37 | } 38 | 39 | /** 40 | * @throws \Exception 41 | */ 42 | public function testCanHandleApplications(): void 43 | { 44 | // Create it 45 | $response = $this->client->createApplication(null, ["application" => ["name" => "PHP Client Application"]]); 46 | $this->handleResponse($response); 47 | $this->applicationId = $response->successResponse->application->id; 48 | 49 | // Retrieve it 50 | $response = $this->client->retrieveApplication($this->applicationId); 51 | $this->handleResponse($response); 52 | $this->assertEquals("PHP Client Application", $response->successResponse->application->name); 53 | 54 | // Update it 55 | $response = $this->client->updateApplication( 56 | $this->applicationId, 57 | ["application" => ["name" => "PHP Client Application Updated"]] 58 | ); 59 | $this->handleResponse($response); 60 | $this->assertEquals("PHP Client Application Updated", $response->successResponse->application->name); 61 | 62 | // Retrieve it again 63 | $response = $this->client->retrieveApplication($this->applicationId); 64 | $this->handleResponse($response); 65 | $this->assertEquals("PHP Client Application Updated", $response->successResponse->application->name); 66 | 67 | // Deactivate it 68 | $response = $this->client->deactivateApplication($this->applicationId); 69 | $this->handleResponse($response); 70 | 71 | // Retrieve it again 72 | $response = $this->client->retrieveApplication($this->applicationId); 73 | $this->handleResponse($response); 74 | $this->assertFalse($response->successResponse->application->active); 75 | 76 | // Retrieve inactive 77 | $response = $this->client->retrieveInactiveApplications(); 78 | $this->assertEquals("PHP Client Application Updated", $response->successResponse->applications[0]->name); 79 | 80 | // Reactivate it 81 | $response = $this->client->reactivateApplication($this->applicationId); 82 | $this->handleResponse($response); 83 | 84 | // Retrieve it again 85 | $response = $this->client->retrieveApplication($this->applicationId); 86 | $this->handleResponse($response); 87 | $this->assertEquals("PHP Client Application Updated", $response->successResponse->application->name); 88 | $this->assertTrue($response->successResponse->application->active); 89 | 90 | // Delete it 91 | $response = $this->client->deleteApplication($this->applicationId); 92 | $this->handleResponse($response); 93 | 94 | // Retrieve it again 95 | $response = $this->client->retrieveApplication($this->applicationId); 96 | $this->assertEquals(404, $response->status); 97 | 98 | // Retrieve inactive 99 | $response = $this->client->retrieveInactiveApplications(); 100 | $this->assertEmpty($response->successResponse->applications); 101 | } 102 | 103 | /** 104 | * @throws \Exception 105 | */ 106 | public function testCanHandleUsers(): void 107 | { 108 | // Create it 109 | $response = $this->client->createUser( 110 | null, 111 | ["user" => ["email" => "test@fusionauth.io", "password" => "password", "firstName" => "Jäne"]] 112 | ); 113 | $this->handleResponse($response); 114 | $this->userId = $response->successResponse->user->id; 115 | 116 | // Retrieve it 117 | $response = $this->client->retrieveUser($this->userId); 118 | $this->handleResponse($response); 119 | $this->assertEquals("test@fusionauth.io", $response->successResponse->user->email); 120 | 121 | // Login 122 | $response = $this->client->login(["loginId" => "test@fusionauth.io", "password" => "password"]); 123 | $this->handleResponse($response); 124 | $this->assertEquals("test@fusionauth.io", $response->successResponse->user->email); 125 | 126 | // Update it 127 | $response = $this->client->updateUser($this->userId, ["user" => ["email" => "test+2@fusionauth.io"]]); 128 | $this->handleResponse($response); 129 | $this->assertEquals("test+2@fusionauth.io", $response->successResponse->user->email); 130 | 131 | // Retrieve it again 132 | $response = $this->client->retrieveUser($this->userId); 133 | $this->handleResponse($response); 134 | $this->assertEquals("test+2@fusionauth.io", $response->successResponse->user->email); 135 | 136 | // Deactivate it 137 | $response = $this->client->deactivateUser($this->userId); 138 | $this->handleResponse($response); 139 | 140 | // Retrieve it again 141 | $response = $this->client->retrieveUser($this->userId); 142 | $this->handleResponse($response); 143 | $this->assertFalse($response->successResponse->user->active); 144 | 145 | // Reactivate it 146 | $response = $this->client->reactivateUser($this->userId); 147 | $this->handleResponse($response); 148 | 149 | // Retrieve it again 150 | $response = $this->client->retrieveUser($this->userId); 151 | $this->handleResponse($response); 152 | $this->assertEquals($response->successResponse->user->email, "test+2@fusionauth.io"); 153 | $this->assertTrue($response->successResponse->user->active); 154 | 155 | // Delete it 156 | $response = $this->client->deleteUser($this->userId); 157 | $this->handleResponse($response); 158 | 159 | // Retrieve it again 160 | $response = $this->client->retrieveUser($this->userId); 161 | $this->assertEquals(404, $response->status); 162 | } 163 | 164 | /** 165 | * @throws \Exception 166 | */ 167 | public function testCanLogoutWithoutRefreshToken(): void 168 | { 169 | // Without parameter 170 | $response = $this->client->logout(true, null); 171 | $this->handleResponse($response); 172 | } 173 | 174 | /** 175 | * @throws \Exception 176 | */ 177 | public function testCanLogoutWithRefreshToken(): void 178 | { 179 | // With NULL 180 | $response = $this->client->logout(true, 'refresh_token'); 181 | $this->handleResponse($response); 182 | } 183 | 184 | /** 185 | * @throws \Exception 186 | */ 187 | public function testCanLogoutWithBogusToken(): void 188 | { 189 | // With bogus token 190 | $response = $this->client->logout(false, "token"); 191 | $this->handleResponse($response); 192 | } 193 | 194 | /** 195 | * @param $response ClientResponse 196 | */ 197 | private function handleResponse(ClientResponse $response): void 198 | { 199 | if (!$response->wasSuccessful()) { 200 | fwrite(STDERR, "Status: " . $response->status . PHP_EOL); 201 | fwrite(STDERR, json_encode($response->errorResponse, JSON_PRETTY_PRINT) . PHP_EOL); 202 | } 203 | 204 | $this->assertTrue( 205 | $response->wasSuccessful(), 206 | "Expected success. Status: {$response->status}" 207 | ); 208 | } 209 | } 210 | --------------------------------------------------------------------------------