{"id":14989816,"url":"https://github.com/auth0/auth0-php","last_synced_at":"2025-05-13T22:12:22.187Z","repository":{"id":11276315,"uuid":"13683710","full_name":"auth0/auth0-PHP","owner":"auth0","description":"PHP SDK for Auth0 Authentication and Management APIs.","archived":false,"fork":false,"pushed_at":"2025-05-07T17:02:53.000Z","size":6566,"stargazers_count":394,"open_issues_count":2,"forks_count":215,"subscribers_count":77,"default_branch":"main","last_synced_at":"2025-05-07T17:47:40.135Z","etag":null,"topics":["auth0","dx-sdk","php"],"latest_commit_sha":null,"homepage":"https://auth0.com/docs/libraries/auth0-php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.ARCHIVE.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-10-18T16:51:11.000Z","updated_at":"2025-05-05T05:26:07.000Z","dependencies_parsed_at":"2023-12-05T19:27:09.282Z","dependency_job_id":"65b0b754-0b64-4000-85d7-2959a352e0c2","html_url":"https://github.com/auth0/auth0-PHP","commit_stats":{"total_commits":1377,"total_committers":100,"mean_commits":13.77,"dds":0.747276688453159,"last_synced_commit":"7ffdf4e6e1ffbb8066aaebf0f6432d5181db00b9"},"previous_names":[],"tags_count":127,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fauth0-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/auth0-PHP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036843,"owners_count":22003654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth0","dx-sdk","php"],"created_at":"2024-09-24T14:18:57.755Z","updated_at":"2025-05-13T22:12:17.176Z","avatar_url":"https://github.com/auth0.png","language":"PHP","readme":"![auth0-php](https://cdn.auth0.com/website/sdks/banners/auth0-php-banner.png)\n\nPHP SDK for [Auth0](https://auth0.com) Authentication and Management APIs.\n\n[![Package](https://img.shields.io/packagist/dt/auth0/auth0-php)](https://packagist.org/packages/auth0/auth0-php)\n[![Build Status](https://github.com/auth0/auth0-PHP/actions/workflows/tests.yml/badge.svg)](https://github.com/auth0/auth0-PHP/actions/workflows/tests.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/auth0/auth0-PHP/main)](https://codecov.io/gh/auth0/auth0-PHP)\n[![License](https://img.shields.io/github/license/auth0/auth0-PHP)](https://doge.mit-license.org/)\n\n:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :computer: [API Reference](#api-reference) :speech_balloon: [Feedback](#feedback)\n\n## Documentation\n\nWe also have tailored SDKs for [Laravel](https://github.com/auth0/laravel-auth0), [Symfony](https://github.com/auth0/symfony), and [WordPress](https://github.com/auth0/wordpress). If you are using one of these frameworks, use the tailored SDK for the best integration experience.\n\n- Quickstarts\n  - [Application using Sessions (Stateful)](https://auth0.com/docs/quickstart/webapp/php) — 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.](https://github.com/auth0-samples/auth0-php-web-app)\n  - [API using Access Tokens (Stateless)](https://auth0.com/docs/quickstart/backend/php) — 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.](https://github.com/auth0-samples/auth0-php-api-samples)\n- [PHP Examples](./EXAMPLES.md) — Code samples for common scenarios.\n- [Documentation Hub](https://www.auth0.com/docs) — Learn more about integrating Auth0 with your application.\n\n## Getting Started\n\n### Requirements\n\n- PHP 8.1+\n- [Composer](https://getcomposer.org/)\n- PHP Extensions:\n  - [mbstring](https://www.php.net/manual/en/book.mbstring.php)\n- Dependencies:\n  - [PSR-18 HTTP Client implementation](./FAQ.md#what-is-psr-18)\n  - [PSR-17 HTTP Factory implementation](./FAQ.md#what-is-psr-17)\n  - [PSR-7 HTTP Messages implementation](./FAQ.md#what-is-psr-7)\n\n\u003e Please review our [support policy](#support-policy) for details on our PHP version support.\n\n### Installation\n\nEnsure you have [the necessary dependencies](#requirements) installed, then add the SDK to your application using [Composer](https://getcomposer.org/):\n\n```\ncomposer require auth0/auth0-php --no-dev\n```\n\n### Configure Auth0\n\nCreate a **Regular Web Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications). Verify that the \"Token Endpoint Authentication Method\" is set to `POST`.\n\nNext, configure the callback and logout URLs for your application under the \"Application URIs\" section of the \"Settings\" page:\n\n- **Allowed Callback URLs**: The URL of your application where Auth0 will redirect to during authentication, e.g., `http://localhost:3000/callback`.\n- **Allowed Logout URLs**: The URL of your application where Auth0 will redirect to after user logout, e.g., `http://localhost:3000/login`.\n\nNote the **Domain**, **Client ID**, and **Client Secret**. These values will be used later.\n\n### Add login to your application\n\nCreate 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.\n\n```php\nuse Auth0\\SDK\\Auth0;\nuse Auth0\\SDK\\Configuration\\SdkConfiguration;\n\n$configuration = new SdkConfiguration(\n    domain: 'Your Auth0 domain',\n    clientId: 'Your Auth0 application client ID',\n    clientSecret: 'Your Auth0 application client secret',\n    cookieSecret: 'Your generated string',\n);\n\n$auth0 = new Auth0($configuration);\n```\n\nUse the `getCredentials()` method to check if a user is authenticated.\n\n```php\n// getCredentials() returns null if the user is not authenticated.\n$session = $auth0-\u003egetCredentials();\n\nif (null === $session || $session-\u003eaccessTokenExpired) {\n    // Redirect to Auth0 to authenticate the user.\n    header('Location: ' . $auth0-\u003elogin());\n    exit;\n}\n```\n\nComplete the authentication flow and obtain the tokens by calling `exchange()`:\n\n```php\nif (null !== $auth0-\u003egetExchangeParameters()) {\n    $auth0-\u003eexchange();\n}\n```\n\nFinally, you can use `getCredentials()?-\u003euser` to retrieve information about our authenticated user:\n\n```php\nprint_r($auth0-\u003egetCredentials()?-\u003euser);\n```\n\n**That's it! You have successfully authenticated your first user with Auth0!** From here, you may want to try following along with [one of our quickstarts](#documentation) or browse through [our examples](./EXAMPLES.md) for additional insight and guidance.\n\nIf you have questions, the [Auth0 Community](https://community.auth0.com/) is a fantastic resource to ask questions and get help.\n\n## Input from Untrusted Sources\n\nIf 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](https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html).\n\n## API Reference\n\n- [API Reference](https://auth0.github.io/auth0-PHP/)\n\n## Support Policy\n\nOur support lifecycle mirrors the [PHP release support schedule](https://www.php.net/supported-versions.php).\n\n| SDK Version | PHP Version | Support Ends |\n| ----------- | ----------- | ------------ |\n| 8           | 8.3         | Dec 2027     |\n|             | 8.2         | Dec 2026     |\n|             | 8.1         | Dec 2025     |\n\nWe 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.\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Contribution Guide](./CONTRIBUTING.md)\n- [Auth0's General Contribution Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's Code of Conduct Guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n\n### Raise an issue\n\nTo provide feedback or report a bug, [please raise an issue on our issue tracker](https://github.com/auth0/auth0-PHP/issues).\n\n### Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\"\u003e\n    \u003cimg alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eAuth0 is an easy-to-implement, adaptable authentication and authorization platform.\u003cbr /\u003eTo learn more, check out \u003ca href=\"https://auth0.com/why-auth0\"\u003e\"Why Auth0?\"\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eThis project is licensed under the MIT license. See the \u003ca href=\"./LICENSE.md\"\u003eLICENSE file\u003c/a\u003e for more info.\u003c/p\u003e\n","funding_links":[],"categories":["Developer Ecosystem"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fauth0-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fauth0-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fauth0-php/lists"}