Download the PHP package auth0/auth0-php without Composer
On this page you can find all versions of the php package auth0/auth0-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download auth0/auth0-php
More information about auth0/auth0-php
Files in auth0/auth0-php
Package auth0-php
Short Description PHP SDK for Auth0 Authentication and Management APIs.
License MIT
Homepage https://github.com/auth0/auth0-PHP
Rated 5.00 based on 1 reviews
Informations about the package auth0-php

PHP SDK for Auth0 Authentication and Management APIs.
:books: Feedback
Documentation
We also have tailored SDKs for Laravel, Symfony, and WordPress. If you are using one of these frameworks, use the tailored SDK for the best integration experience.
- Quickstarts
- Application using Sessions (Stateful) - Demonstrates a traditional web application that uses sessions and supports logging in, logging out, and querying user profiles. The completed source code is also available.
- API using Access Tokens (Stateless) - Demonstrates a backend API that authorizes endpoints using access tokens provided by a frontend client and returns JSON. The completed source code is also available.
- PHP Examples - Code samples for common scenarios.
- Documentation Hub - Learn more about integrating Auth0 with your application.
Getting Started
Requirements
- PHP 8.2+
- Composer
- PHP Extensions:
- Dependencies:
- PSR-18 HTTP Client implementation
- PSR-17 HTTP Factory implementation
- PSR-7 HTTP Messages implementation
Please review our support policy for details on our PHP version support.
Installation
Ensure you have Composer:
Configure Auth0
Create a Regular Web Application in the Auth0 Dashboard. Verify that the "Token Endpoint Authentication Method" is set to POST.
Next, configure the callback and logout URLs for your application under the "Application URIs" section of the "Settings" page:
- Allowed Callback URLs: The URL of your application where Auth0 will redirect to during authentication, e.g.,
http://localhost:3000/callback. - Allowed Logout URLs: The URL of your application where Auth0 will redirect to after user logout, e.g.,
http://localhost:3000/login.
Note the Domain, Client ID, and Client Secret. These values will be used later.
Add login to your application
Create a SdkConfiguration instance configured with your Auth0 domain and Auth0 application client ID and secret. Generate a sufficiently long, random string for your cookieSecret using openssl rand -hex 32. Create a new Auth0 instance and pass your configuration to it.
Use the getCredentials() method to check if a user is authenticated.
Complete the authentication flow and obtain the tokens by calling exchange():
Finally, you can use getCredentials()?->user to retrieve information about our authenticated user:
That's it! You have successfully authenticated your first user with Auth0! From here, you may want to try following along with our examples for additional insight and guidance.
If you have questions, the Auth0 Community is a fantastic resource to ask questions and get help.
Authentication API
The Authentication API handles user authentication flows. Initialize it with your Auth0 configuration:
Common Operations
[!WARNING] Never pass unsanitized user input into the
$paramsargument ofgetLoginLink(),login(), orgetLogoutLink(). Caller-supplied values such asredirect_uriare used to build the authorization request, so always source them from trusted, explicit values. The SDK ignores attempts to overrideclient_id,response_type, andresponse_modevia$params.See EXAMPLES.md for Custom Token Exchange, including session login and actor-token delegation.
Database Connection Operations
Management API Client
The ManagementClient wrapper provides a convenient way to interact with the Auth0 Management API with automatic token management. It wraps the generated Management client and handles authentication transparently - you get the same sub-client access (->users, ->roles, etc.) without managing tokens yourself.
Static Token
Use a pre-existing access token:
Client Credentials (M2M)
Provide client ID and secret to have the wrapper automatically fetch and refresh tokens via the OAuth 2.0 client credentials grant:
The audience defaults to https://{domain}/api/v2/ but can be overridden:
Token Caching (PSR-6)
By default, tokens are cached in-memory and are lost when the PHP process ends. To persist tokens across requests (avoiding a client credentials grant on every request), pass any PSR-6 cache implementation:
Any PSR-6 CacheItemPoolInterface implementation works - for example FilesystemAdapter, RedisAdapter, ApcuAdapter, or Memcached from symfony/cache. The token TTL is set automatically based on the expires_in value from Auth0.
Custom Token Provider
For full control over token acquisition, pass a callable that returns a token string:
Additional Options
ManagementClientOptions accepts several optional parameters:
| Option | Type | Description |
|---|---|---|
httpClient |
ClientInterface |
Custom PSR-18 HTTP client (e.g. Guzzle, Symfony HttpClient) |
timeout |
float |
Request timeout in seconds |
maxRetries |
int |
Maximum number of request retries |
additionalHeaders |
array<string, string> |
Extra headers to include in requests |
tokenCache |
CacheItemPoolInterface |
PSR-6 cache pool for persisting management tokens |
Exception Handling
When the API returns a non-success status code (4xx or 5xx response), an exception will be thrown.
Pagination
List endpoints return a Pager<T> which lets you loop over all items and the SDK will automatically make multiple HTTP requests for you.
You can also iterate page-by-page:
Sending Explicit Nulls
When updating resources with PATCH endpoints, the SDK distinguishes between omitting a field (don't change it) and sending null (clear it). By default, null properties are omitted from the request body. To explicitly send a null value, use the setter method instead of passing it through the constructor:
Setters mark the property as explicitly set, so the serializer includes it even when the value is null. This works for any property on any request object, and setters can be chained:
Advanced
Custom Client
This SDK works with any PSR-18 HTTP client. By default, the SDK auto-discovers an installed client using HTTPlug Discovery. You can pass your own client that implements Psr\Http\Client\ClientInterface:
The same httpClient option is available on ManagementClientOptions for the wrapper:
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
Use the maxRetries request option to configure this behavior.
Timeouts
The SDK defaults to a 30 second timeout. Use the timeout option to configure this behavior.
Input from Untrusted Sources
If your application accepts input from untrusted sources (such as query parameters from HTTP requests) please ensure you are following best practices for data validation and sanitization. It is your application's responsibility to ensure any data provided to the SDK is valid and safe. For more information, see the OWASP Data Validation Cheat Sheet.
API Reference
- Authentication API Reference
- Management API Reference
Support Policy
Our support lifecycle mirrors the PHP release support schedule.
| SDK Version | PHP Version | Support Ends |
|---|---|---|
| 9 | 8.4 | Dec 2028 |
| 8.3 | Dec 2027 | |
| 8.2 | Dec 2026 |
We drop support for PHP versions when they reach end-of-life and cease receiving security fixes from the PHP Foundation. Please ensure your environment remains up to date so you can continue receiving updates for PHP and this SDK.
Feedback
Contributing
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
- Contribution Guide
- Auth0's General Contribution Guidelines
- Auth0's Code of Conduct Guidelines
Note: The Management API client in this SDK is generated programmatically using Fern. Contributions to the Management API layer should be directed to the generation configuration rather than the generated source files. The Authentication API and all other SDK components are hand-written and accept direct contributions.
Raise an issue
To provide feedback or report a bug, please raise an issue on our issue tracker.
Vulnerability Reporting
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 is an easy-to-implement, adaptable authentication and authorization platform.
To learn more, check out "Why Auth0?"
This project is licensed under the MIT license. See the LICENSE file for more info.
All versions of auth0-php with dependencies
ext-json Version *
ext-mbstring Version *
ext-openssl Version *
php-http/discovery Version ^1.0
php-http/multipart-stream-builder Version ^1
psr-discovery/all Version ^1
psr/http-client Version ^1.0
psr/http-client-implementation Version ^1
psr/http-factory Version ^1.0
psr/http-factory-implementation Version ^1
psr/http-message Version ^1.1 || ^2.0
psr/http-message-implementation Version ^1